Path: utzoo!mnetor!uunet!mcvax!unido!tub!tmpmbx!csch From: csch@tmpmbx.UUCP (Clemens Schrimpe) Newsgroups: comp.unix.wizards Subject: Re: Redirect Output in the Middle of a Program?? Message-ID: <819@tmpmbx.UUCP> Date: 28 Apr 88 12:59:19 GMT References: <13085@brl-adm.ARPA> <3571@gryphon.CTS.COM> <2841@cvl.umd.edu> Reply-To: csch@tmpmbx.UUCP (Clemens Schrimpe) Organization: netmbx GbR, Berlin Lines: 31 Larry Liuqing Huang (liuqing@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@tmpmbx = {pyramid!tub!unido}!tmpmbx!csch BITNET: csch@db0tui6 csch@tub.BITNET PHONE: +49-30-332 40 15 FAX: +49-30-361 40 93 TELEX: 186672 net d