Stdout and Stderr

David T. Lewis lewis at mail.msen.com
Fri Jan 19 11:47:50 UTC 2007


On Fri, Jan 19, 2007 at 11:16:28AM +0100, Bert Freudenberg wrote:
> 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:
> >>>
> >>>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.

Unfortunately, this is hard to do in a platform-independent manner.
For example, Windows requires a separate thread to handle non-blocking
input, which seems like a lot of complexity for a primitive. And on
Windows, the stdin/stdout/stderr streams are not really very useful.
I don't know the situation for RiscOS and other platforms.

My impression (but I could be wrong) is that most people who care
about using stdin/stdout/stderr are using a unix-based platform
(including OS X), and the access to stdout/stderr and nonblocking
stdin is already available on those platforms. Of course, not too
many people *know* that it's available because it's partly hidden
away in an external package on SqueakMap, but that would be a poor
argument for adding more features to the base Squeak ;-)

Dave

p.s. The primitives for opening stdin/stdout/stderr are already
in OSPP for Windows, but I never did get nonblocking input to
work reliably.  I should go back and give it another try one of
these days.




More information about the Squeak-dev mailing list