stdout buffering question
Michael Meissner
gamma at rtp47.UUCP
Wed Apr 17 10:04:02 AEST 1985
>
> I am trying to exec a child with its standard in, out and error
> directed to pipes. I have managed to accomplish this in two different
> ways, closing the std stuff, duping to the pipes and by execing the shell
> with appropriate arguments. The snag I have run into is that it appears
> that when a process is execed the operating system does you a favor and
> make stdout buffered. ...
First, the decision on whether to buffer is not done at exec time, but rather
in the standard I/O library when you first write to the file. Different
systems make different decisions on when to buffer. Typically, if the
output is a console, it is either unbuffered (BSD?), or line buffered (system
V). Pipes are typically fully buffered for performance reasons. The only
three ways I can see of fixing your problem, is to:
1) Create a pseudo terminal that is opened for write in exec'ing the
child, and for read in the parent.
2) Hack on the standard I/O library to unbuffer pipes, and expect a
possible performance hit on pipes in general. Or, use the hacked
library only in the program you use. Alternatively, hack isatty
to always return 1 (this can be done with a reasonable patch prog.)
3) Try to get the program to use fflush at appropriate times.
Michael Meissner
Data General Corporation
...!mcnc!rti-sel!rtp47!meissner
More information about the Comp.unix
mailing list