Checking for new mail (and killing bkgnd process on logout?)

Rob McMahon cudcv at warwick.ac.uk
Sat Sep 2 22:10:23 AEST 1989


In article <4201 at ncar.ucar.edu> corbet at mead.UCAR.EDU (Jonathan Corbet) writes:
>How about if you add a line like:
>
>	signal (SIGHUP, SIG_DFL);
>
>toward the beginning of your main program?  That will cause the program
>to die when the parent process does...

I've seen a couple of people say things like this now.  It's not that csh sets
its children to ignore SIGHUP, but rather that they never see it.  Csh, at
least on BSD systems with job control, puts each `job' into a process group of
it's own, so that it can manipulate them (stop them as a complete job, move
them into the foreground by setting the process group associated with the
terminal the same as the job, put them into the background by doing the
opposite).

Since only processes in the process group associated with the terminal see
keyboard generated signals, including SIGHUP, background processes never even
have the signals delivered to them.  So the only ways round this are to either
have the shell kill the job before it goes away (by putting something in
.logout), or by having the job check that its parent is still around
occasionally, by checking the value of ppid(), or by kill(orig_ppid, 0)'ing.

Rob
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv at uk.ac.warwick             ARPA:   cudcv at warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England



More information about the Comp.unix.wizards mailing list