Redirect Output in the Middle of a Program??
Clemens Schrimpe
csch at tmpmbx.UUCP
Thu Apr 28 22:59:19 AEST 1988
Larry Liuqing Huang (liuqing at cvl.UUCP) writes:
{} Now more people are dialing into a system via telephone lines. It is
{} not unusual that the connection died out in the middle of a big C
{} program which you hate to start running from the beginning again.
{}
{} Is it possible for the C program or Shell to detect the line problem?
Sure! The system will generate a SIGHUP (Hangup) signal to all processes,
which have the "hung-up" tty as their controlling tty.
[this will work ONLY, if you are using a tty, which supports modem-control
signals (mainly DTR & DCD) and this modem-control is also enabled
(~CLOCAL, HUPCL and open with ~O_NDELAY)]
{} If so, is it possible to redirect all standard output and error messages
{} to a designated file from the POINT where the problem is detected and
{} continue running?
Sure (normally :-)
Simply catch the SIGHUP, close 0, reopen it on /dev/null and
close 1 & 2 and reopen both on the file you want, then return from
the signal-routine. I havn't tried this, but it should work.
{} Any hints highly appreciated.
Ya' welcome ... ]:-}
Clemens Schrimpe
UUCP: csch at tmpmbx = {pyramid!tub!unido}!tmpmbx!csch
BITNET: csch at db0tui6 csch at tub.BITNET
PHONE: +49-30-332 40 15
FAX: +49-30-361 40 93
TELEX: 186672 net d
More information about the Comp.unix.wizards
mailing list