Endangered I/O operations

Carl R. Witty cwitty@newtonlabs.com
23 May 2001 11:35:24 -0700

"Simon Marlow" <simonmar@microsoft.com> writes:

> You obtain the ordering properties by setting the handle to NoBuffering,
> otherwise you get buffered input/output.  Wouldn't it be deviating from
> the report to do extra flushing in the buffered case?  (this is
> something of a technicality, actually we already do non-report flushing
> in several cases and our line-buffered input isn't line-buffered at
> all).

If the report does not allow the implementation to flush buffers at
any time, I would call that a bug in the report.  I would much rather
use an implementation where stdout and stderr came out in the right
order, and reading from stdin flushed stdout.  (As another example, an
implementation might want to flush all buffers before doing a fork(),
to avoid duplicated output.)

The only caveat is that if such flushing is allowed but not required,
it might encourage writing sloppy, nonportable code.

Carl Witty