[Vm-dev] Stdin/stdout/stderr support

David T. Lewis lewis at mail.msen.com
Sun Aug 31 20:36:04 UTC 2008

On Sat, Aug 30, 2008 at 04:43:46PM +0300, Igor Stasenko wrote:
> 2008/8/30 David T. Lewis <lewis at mail.msen.com>:
> >
> > For example, here is the Windows implementation from OSPP:
> >
> Good, but maybe it can be more simplier?
> Just return a valid file handle on success, or fail primitive if not.

Sure. That's what I did for the Unix flavor, and I don't recall why
I did it differently for win32. I think that it was a convenient way
to tell whether the Windows console was open or not.

> Also, it can be a single prim (primitiveGetStdFileHandle) , with
> additional argument indicating which std stream to return e.g.
> 0 - for stdin
> 1 - for stdout
> 2 - for stderr

I preferred the three separate methods versus "magic numbers", but
either way is fine.

One other thing I might mention. The stdin stream is dangerous because
it will hang the image on a blocking read if no data is available.
For OSPP I added primitives to set nonblocking I/O, and this would
need to be addressed if stdin access is made part of the normal VM.


More information about the Vm-dev mailing list