stdio buffering considered harmful

noel at cubsvax.UUCP noel at cubsvax.UUCP
Thu Jul 28 01:11:01 AEST 1983


I have run into the stdout buffering headache several times, most
painfully when piping from an interactive fortran program.
(Who wants to hack a -u flag into a large f77 program? I reluctantly did
the equivalent).  My problem was when using "script" or "tee", that stdout
wasn't flushed when the program did a read on stdin.  Is there a more general
problem? I suppose in some cases you might need LINE buffering even when
it's a unidirectional communication path too (the pipe reader
wants to read line by line (why??)).

Considering just the "interactive" case.. why couldn't stdio be smart
enough to check for stdout being a pipe, then flush it when stdin is
read?  This way you wouldn't pay the performance penalty of ALWAYS
line buffering on pipes, but fix the (most common?) problem with the current
scheme.  What am I missing?

	Noel Kropf		harpo!rocky2!cubsvax!noel
	1002 Fairchild		philabs!cmcl2!rocky2!cubsvax!noel
	Columbia University
	New York NY 10027	212-280-5517
-- 
	Noel Kropf		harpo!rocky2!cubsvax!noel
	1002 Fairchild		philabs!cmcl2!rocky2!cubsvax!noel
	Columbia University
	New York NY 10027	212-280-5517



More information about the Comp.unix.wizards mailing list