Redirect Output in the Middle of a Program??

Chris Torek chris at mimsy.UUCP
Thu Apr 28 20:13:22 AEST 1988


In article <62 at denali.UUCP> karish at denali.UUCP (karish) writes:
>... The user's program can catch the SIGHUP, using a signal handler
>assigned by the signal() function.  This handler can use fopen() to
>open outfiles, and freopen() to reassign the output streams.

This is quite dangerous.  The proposed technique is likely to work
until you need it to do so.  A SIGHUP can occur while all sorts of
internal states are inconsistent; opening a new stream, or reopening an
existing one, is liable to result in a core dump or lost or duplicated
output.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list