Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uflorida!haven!mimsy!chris
From: chris@mimsy.UUCP (Chris Torek)
Newsgroups: comp.unix.wizards
Subject: setlinebuf(stdin)
Keywords: open(2), close(2), exit(2)
Message-ID: <12994@mimsy.UUCP>
Date: 14 Aug 88 06:01:30 GMT
References: <1122@ssc-bee.ssc-vax.UUCP> <291@quintus.UUCP>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 16

In article <291@quintus.UUCP> ok@quintus.uucp (Richard A. O'Keefe) writes:
>The remedy is simple.  Only your program needs to change.
>Before reading from stdin, do
>	setbuf(stdin, (char*)NULL);	/* all flavours */
>or	setlinebuf(stdin);		/* BSD */
>or use setvbuf in System V.

Setlinebuf() has no effect on input streams.  I imagine setvbuf will
not set line-at-a-time reading on SysV either.  Think about it:  how
will you tell the system to read only up through a newline?

Using setbuf(stdin, (char *)NULL) will do the trick, but is terribly
inefficient.  I prefer my fseek-before-exit suggestion . . . .
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris