[comp.sources.d] "monthd" doesn't terminate BSD & SIGHUP

jiml@uwslh.UUCP (James E. Leinweber) (11/19/88)

On systems derived from 4.2 BSD Unix, such as Ultrix, SIGHUP is
broken.  Bezerkely usurped the traditional notion of process group ==
login session for job control.  When you log out, only processes in
the current "job" get SIGHUP, and background jobs blithely become orphans.

The only plausible way for a background process itself to tell if its
spawning login session has died is to (dramamine mode: ON :-) watch
/etc/utmp to see if ownership of its controlling tty has changed.
Even this fails if the same user logs back in on the same line faster
than the daemon is waking.  Those with strong stomachs can look at
"sysline" source to see how it is done - if you have the problem,
there is a fair chance you *have* sysline source!

However, the easiest solution is to keep track of what background
notifiers you are running, and have your .logout (Csh users) or trap 0
function (Ksh users) manually send them a SIGHUP.  This is easy for
sysline users, since it has an option to write it's pid to standard
output.  For monthd the easiest killer is probably something like:

	kill -HUP `ps -x|egrep monthd|sed 's/ .*//'`

Jim Leinweber		jiml@uwslh.uucp		jiml%uwslh.uucp@cs.wisc.edu
 ...!{rutgers, ucbvax ...}!uwvax!uwslh!jiml
State Laboratory of Hygiene @ Univ. of Wisconsin - Madison; (608) 262-0736
-- 
Jim Leinweber		jiml@uwslh.uucp		jiml%uwslh.uucp@cs.wisc.edu
 ...!{rutgers, ucbvax ...}!uwvax!uwslh!jiml
State Laboratory of Hygiene @ Univ. of Wisconsin - Madison; (608) 262-0736