Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Mar 1996 01:35:55 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        mbarkah@hemi.com (Ade Barkah)
Cc:        hackers@FreeBSD.org
Subject:   Re: Help, processes not getting killed when users exit
Message-ID:  <199603300835.BAA07024@phaeton.artisoft.com>
In-Reply-To: <199603300601.XAA11875@hemi.com> from "Ade Barkah" at Mar 29, 96 11:01:37 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> [I'm using FreeBSD 2.1-R]
> 
> I've noticed that some of my processes aren't getting killed when 
> the connection is broken, and I've been trying to figure out why
> this is. Some of the programs which (sometimes) stay alive include
> 'vi' and 'irc'... they go into a loop trying to perform I/O on
> the pty and drive up CPU usage like mad (they don't seem to check
> the result of their read() calls.)
> 
> Suppose a remote telnet connection disconnects. Telnetd notices
> it, calls cleanup(), and exits. How do the shell and the application
> get notified ? I.e., which process is responsible in sending a
> SIGHUP to the user's processes ?

When the telnetd exits, it closes the master size of the pty (the
shell and any user apps are running on the slave side).

When this happens, if the slave side is set HUPCL, then a SIGHUP
is sent to the controlling process.  If this process is group
leader (it is), then it is supposed to send SIGHUP to all processes
in the process group (it doesn't do that because the wording of POSIX
is vague in this regard as to order of delivery vs. where default
handling occurs: in the process or in the kernel).

What happens instead on BSD, is that the close of the master causes
a "revoke".  Processes that don't trap read returns for EOF will
go into a tight loop; those that do, will exit, just like if BSD
had properly delivered the SIGHUP to the child processes (like
POSIX implies you shouldn't, and like SunOS, Solaris, HPUX, SCO,
Linux, BSDI, Ultrix, OSF/1, SVR3, SVR4, and AIX all do...).


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603300835.BAA07024>