Output redirection

Blair P. Houghton bhoughto at cmdnfs.intel.com
Sat Oct 20 02:28:51 AEST 1990


In article <15479 at hydra.gatech.EDU> gt0178a at prism.gatech.EDU (Jim Burns) writes:
>in article <3447 at idunno.Princeton.EDU>, pfalstad at phoenix.Princeton.EDU (Paul John Falstad) adds:
>
>> 	setlinebuf(stdout);  /* this should fix it */
>
>to Abhay B. Joshi's c code. Let's assume a situation where you don't have
>the source code. How would you synchronize output only thru shell
>mechanisms?

You wouldn't.  The shell has no control over buffering
done by binary executables.  setlinebuf() in the c code
is more certain.  Abhay apparently thought the newlines
would force a buffer-flushing; setlinebuf() fixed the
program to fit that concept.

If you want the output completely unbuffered (which hogs CPU
and I/O resources if you are using it with functions that
write more than one char at a time) use setbuf(stdout,NULL)
and setbuf(stderr,NULL).

				--Blair
				  "setbuf(usenet,NULL,apparently...)"



More information about the Comp.unix.shell mailing list