Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rtp47.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!harvard!talcott!panda!genrad!decvax!mcnc!rti-sel!rtp47!gamma From: gamma@rtp47.UUCP (Michael Meissner) Newsgroups: net.unix Subject: Re: stdout buffering question Message-ID: <26@rtp47.UUCP> Date: Tue, 16-Apr-85 19:04:02 EST Article-I.D.: rtp47.26 Posted: Tue Apr 16 19:04:02 1985 Date-Received: Sun, 21-Apr-85 01:38:38 EST References: <749@druxr.UUCP> Organization: Data General, RTP, NC Lines: 27 > > 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