[net.bugs.4bsd] msgs can truncate all messages once interrupted

jpl@allegra.UUCP (John P. Linderman) (03/12/85)

Index:	ucb/msgs/msgs.c 4.2BSD

Description:
	If one runs
	    msgs
	and interrupts it during a long printout, only a single line
	of all subsequent messages may be displayed.
Repeat-By:
	Run
	    msgs -50
	to get the last 50 messages.  Don't use the -p option.  Hit
	interrupt while it is printing a long message.  If you do this
	often enough, only the first line of each message will be
	displayed for all subsequent messages.
Fix:
	The problem is that interrupting the printout can cause a write
	error on stdout.  (This won't always happen, which is why you
	must bash on interrupt for several messages before it may appear.)
	If and when the error occurs, ferror(stdout) will remain true,
	and the loop that prints the messages will be exited after
	printing a single line.

	An easy fix is to clear any existing error before attempting to
	print each message in prmesg().  A context diff of msgs.c follows.

	--- msgs.c	Tue Mar 12 12:06:15 1985
	***************
	*** 558,563
		}
		else
			outf = stdout;
	  
		if (seensubj)
			putc('\n', outf);

	--- 558,564 -----
		}
		else
			outf = stdout;
	+ 	clearerr(outf);
	  
		    if (seensubj)
			    putc('\n', outf);