[912] in Zephyr_Bugs

home help back first fref pref prev next nref lref last post

Re: possibly more useful patch for zwgc to get HUP on logout

daemon@ATHENA.MIT.EDU (Greg Hudson)
Sun Mar 1 20:28:36 1998

Date: Sun, 1 Mar 1998 20:28:34 -0500 (EST)
From: Greg Hudson <ghudson@MIT.EDU>
To: Derrick J Brashear <shadow@DEMENTIA.ORG>
Cc: zephyr-bugs@MIT.EDU
In-Reply-To: "[908] in Zephyr_Bugs"

So, it's clear that there's a real problem here.  The current code for
POSIX systems (setpgid(0, tcgetpgrp(1))) should be a no-op if zwgc is
run in the foreground.  The goal of the non-POSIX code is to add
yourself to the process group of the session leader, but I see no
reason why that would result in zwgc getting a HUP at logout time
(unless there happen to be stopped jobs at that point, because of what
happens to orphaned process groups, at least under NetBSD).

I'm not convinced that your patch makes the situation any better.
getsid() is a more robust way of finding the session leader than
getpgrp(getppid()), but as far as I can tell being in the progress
group of the session leader doesn't guarantee that you'll get a HUP at
logout time.  tcgetpgrp(1) (the foreground group of what's presumably
the controlling terminal) should never be terribly useful.  Your patch
also sets ngrp equal to an uninitialized value of pgrp under some
circumstances.

I'm going to do some empirical testing to see if the situation is less
bleak than it looks from the POSIX spec and from kernel source code.

home help back first fref pref prev next nref lref last post