Subtle bug in fflush and fix

Doug Gwyn gwyn at brl-smoke.ARPA
Thu Jul 10 20:46:56 AEST 1986


In article <1781 at milano.UUCP> peterson at milano.UUCP writes:
>The stdio package does not seem to properly account for some effects
>of signals.

This is a tremendous understatement.  Use of signals is so
fraught with peril that X3J11 seriously considered guaranteeing
absolutely nothing whatsoever about what a signal handler can
do.  I personally can't even guarantee that a signal handler
function is entered successfully on most machine architectures.

The problems are not as well known as they should be.  Signals
can impact the design of much of the C library.  AT&T reworked
the standard I/O routines in an attempt to permit the use of
printf() in a signal handler, but they didn't get it quite right
because it is NOT POSSIBLE to get it right, at least not without
severe performance impact.  Many experienced UNIX system
programmers avoid using signals for anything other than
	(1) job control, on Berkeley-like systems;
	(2) synchronous notification of state changes, such
		as SIGWINCH;
	(3) a means of requesting termination of a process.
Certainly they should not be used for IPC.

This is not a criticism of Peterson's bug fixes.  That just
prompted me to mention this in case there is anyone who needs
to be warned.



More information about the Comp.unix.wizards mailing list