Stdout and Stderr

Bert Freudenberg bert at freudenbergs.de
Fri Jan 19 10:16:28 UTC 2007


Am Jan 19, 2007 um 2:37  schrieb David T. Lewis:

> On Thu, Jan 18, 2007 at 08:46:54PM +0100, Bert Freudenberg wrote:
>>
>> Am Jan 18, 2007 um 20:01  schrieb Giovanni Corriga:
>>
>>> Il giorno gio, 18/01/2007 alle 00.27 +0000, Keith Hodges ha scritto:
>>>> Giovanni Corriga wrote:
>>>>> Il giorno mer, 17/01/2007 alle 22.41 +0000, Keith Hodges ha  
>>>>> scritto:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> just a quick question, are any of the VM's particularly the  
>>>>>> unixish
>>>>>> ones, wired to produce output on stdout or stderr. Are there
>>>>>> primitives
>>>>>> for doing so without any plugins?
>>>>>>
>>>>>
>>>>> If you need output only, you can try opening /dev/stdout and /dev/
>>>>> stderr
>>>>> as simple files.
>>>>>
>>>>> This should work on Linux; not sure if it'll work on other Unix
>>>>> systems.
>>>>>
>>>>> 	Giovanni
>>>>>
>>>> Yes that worked!
>>>
>>> Just for the record, this works for reading from  stdin too, but
>>> unfortunately it's a synchronous (blocking) read.
>>
>> Actually, when you use AsyncFile for reading, this works fine :)
>>
>> In the OLPC image I use this to read commands from a pipe issued by
>> an external process.
>
> Yup, and you can also directly set a file stream for nonblocking
> reads with #primitiveSQFileSetNonBlocking (OSPP comes with the
> unix VM).  This permits direct reads from standard input as in
> OSProcess class>>readFromStdIn.
>
> Either way you can safely read from stdin without hanging the image.

Nice. I wonder ... IMHO we should make this available in the general  
VM IMHO. As well as primitives to open stdin/stdout/stderr.

- Bert -





More information about the Squeak-dev mailing list