[comp.unix.wizards] Stdio

hutch@net1.ucsd.edu (Jim Hutchison) (06/13/88)

<>
So how many things break if stderr is line buffered?  (Meaning that when
you get a \n or a full buffer WECF.)

/*    Jim Hutchison   		UUCP:	{dcdwest,ucbvax}!cs!net1!hutch
		    		ARPA:	Hutch@net1.ucsd.edu
Disclaimer:  The cat agreed that it would be o.k. to say these things.  */

chris@mimsy.UUCP (Chris Torek) (06/13/88)

In article <5027@sdcsvax.UCSD.EDU> hutch@net1.ucsd.edu (Jim Hutchison) writes:
>So how many things break if stderr is line buffered?

Not as much as if it is buffered a la stdout (line if tty, else fully),
but still not nothing.  I change uucp with each new release to make it
line buffered; it requires adding fflush() calls in places so that you
can see send/expect strings in a timely manner.

Note that `tar tvf -' printed its `tv' output to stderr; this was one
of the worst offenders in the unbuffered stderr inefficiency game.  The
4.3BSD tar has been fixed (mostly by BRL) by making its stderr line
buffered.

Chris
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

mouse@mcgill-vision.UUCP (der Mouse) (06/23/88)

In article <5027@sdcsvax.UCSD.EDU>, hutch@net1.ucsd.edu (Jim Hutchison) writes:
> So how many things break if stderr is line buffered?  (Meaning that
> when you get a \n or a full buffer WECF.)

Very little will actually break, but it will make stderr next to
useless for debugging.  It would force the poor programmer to follow
ever fprintf(stderr,...) with fflush(stderr) to make up for it - why
uglify everyone's code for no good reason?

The efficiency argument is quite bogus (for stderr).  Stderr is used
for two things: printing error messages (efficiency irrelevant,
buffering probably acceptable) and printing debugging messages
(efficiency irrelevant, buffering definitely harmful).  There are
exceptions to this general rule (tar cvf - being notable), but they are
few enough that inserting a setbuf or setlinebuf call is no great pain.

					der Mouse

			uucp: mouse@mcgill-vision.uucp
			arpa: mouse@larry.mcrcim.mcgill.edu