Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: signal problems on BSD Message-ID: <3014@auspex.auspex.com> Date: 9 Mar 90 19:54:06 GMT References: <1990Mar6.070333.29327@athena.mit.edu> <5913@star.cs.vu.nl> <1990Mar8.084830.9252@athena.mit.edu> Organization: Auspex Systems, Santa Clara Lines: 49 > Because I believe that the kernel SIGHUP functionality only works when >a dialup line or a hard-wired terminal line (i.e. something that init >deals with, I believe) is the login tty in question. Well, it's a bit more complicated. Your original article said: > While sh automatically sends a HUP signal to all its children when you > log out (actually, I'm not sure the shell does this actively; it's > might be a side-effect of the way and process groups et al work in > BSD) ... and Maarten replied: > It's always been the kernel. Quoting from termio(4) on SunOS 4.0.3c: > > Modem Disconnect > If a modem disconnect is detected, and the CLOCAL flag is > not set in the c_cflag field, a SIGHUP signal is sent to all > processes in the distinguished process group associated with > this terminal. ... The latter has been true since Time Immemorial; however, it only delivers the SIGHUP if you actually get a "modem disconnect". Note, though, that both the 4.3BSD and SunOS 4.x pseudo-tty drivers (and, I suspect, the S5R4 pseudo-tty mechanism as well) treat the final "close" of the controller side of a pseudo-tty as being the moral equivalent of a "modem disconnect", and send a SIGHUP exactly as it's done for Carrier Detect dropping on a "real" tty line. So your belief that the kernel SIGHUP functionality only works on a dialup or hardwired terminal line is incorrect; it works on pseudo-ttys as well. However, there is *another* source of SIGHUP. In BSD, "getty", "rlogind", and "telnetd" issue a "vhangup" call on the tty they're using, in order to blow any old processes off that line. One consequence of "vhangup" is that, if the tty is still open, a SIGHUP gets sent to its process group. In System V, when a "process group leader" (a login shell, for example) exits, and: 1) it has a controlling tty and 2) that tty's process group is the process group of which that process is a leader, a SIGHUP is given to that process group. Of course, if you have a job control shell, neither of the SIGHUPs mentioned above will reach background processes, as stated by Maarten.