newmail also displays on console (bug)
Rob McMahon
cudcv at warwick.ac.uk
Sat Mar 18 09:39:58 AEST 1989
I'm cross-posting this to comp.unix.wizards, and sending follow-ups there,
since this has stopped being an elm question. I'll report back here if no-one
else does.
In article <91 at dsinc.UUCP> syd at dsinc.UUCP (Syd Weinstein) writes:
>In article <330 at wubios.wustl.edu> david at wubios.UUCP (David J. Camp) writes:
>:I have studied the code in newmail.c, and I do not see how the process put
>:in the background is automatically killed upon logout. Perhaps someone
>:in-the-know can explain to me how this is done.
>
>It's really very simple. We do nothing, and when the init process sends a
>SIGHUP, we take the default action, to die.
[But processes not in the process group of the terminal on systems with job
control never see the SIGHUP]
This is quite an interesting problem really. If the background process does
not fork, it can check getppid() occasionally, when it returns 1 it knows it
has been orphaned and can exit. If it does fork things gets more tricky. It
can try to kill(shell_pid, 0), but a) not all systems allow this, and b)
there's a chance of pid reuse. The BSD `leave' program uses getlogin() and
compares it against a stashed copy. At least this means that the only person
it's going to annoy is yourself.
Anyone got any better ideas on how a process which forks and carries on
running in the background can detect when the original shell has gone away ?
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