stdout buffering question
CageG
gsc at druxr.UUCP
Sat Apr 13 04:14:14 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. The result is that nothing is written into the pipe
for stdout until the child flushes stdout or the child exits. If in the child
the buffer size is set to 0 using setbuf then every thing works fine. However
one constraint for what I am trying to do is that no changes (like adding the
setbuf call) can be made to the child process. Calling setbuf after I fork
but before the exec doesn't seem to work. The decision to have buffered output
seems to be done at exec time. Does anyone have any idea how to exec a process
and have it maintain the same buffering characteristics as the parent or how
to exec a process and disable the assignment of buffering to stdout outside
the child process? I am out of ideas and am just about to abandon this
redirection problem. Any thoughts or ideas would be greatly appreciated.
Thanks
Gary Cage
druxr!gsc
(303) 538-4947
More information about the Comp.unix
mailing list