hang on exit bug under Linux
Nicolas Williams
Nicolas.Williams at ubsw.com
Fri Dec 14 12:19:15 EST 2001
On Fri, Dec 14, 2001 at 01:58:42AM +0100, Peter Stuge wrote:
> On Thu, Dec 13, 2001 at 05:35:49PM +0100, Wichert Akkerman wrote:
> > Previously John Hardin wrote:
> > > ...so you're saying having a "hung" ssh session is okay if it's
> > > backgrounded?
> >
> > It is if the backgrounded program has not disconnected itself from
> > the pty.
>
> My point exactly. And nothing has hung. The client is lingering, waiting
> for all remote tasks to complete. This is the same behaviour you get if you
> set SO_LINGER on a socket. Check out socket(7).. If/when the program in
> the background (on remotehost) exits, the ssh client and the sshd on the
> server will also exit. And if the xterm (or virtual console) gets closed,
> the ssh client will be killed off, as the sshd on remotehost. If the
> backgrounded program on remotehost catches HUP it will stay alive, but any
> data output from it will be lost. That's however hard to change from within
> ssh.
>
> Now off to code up this patch. Or at least I'll try, had a look at some of
> the code yesterday too but didn't get anywhere..
Cool.
You need options processing code (readconf.c) and session-exit
processing code. When the client gets a session-exit message, and that
was the last session still "alive", then do as the user wanted. The
things to do could be many, as I've suggested before and as I'll repeat:
- do nothing ("hang" until the session's channels are closed)
- background the client (what you suggest)
- force the channels closed and exit (what many users want)
- pass a SIGHUP to the session in question (reading the drafts this can
be done because the session exit message is really associated with the
session's channel, therefore, though the session has exited it
continues to exist until the channels are closed. The server should
kill the process group of the session leader whose exiting elicited
the session-exit message).
You needn't implement all of those options. The first two will do for
you, apparently, so implement that. The others can be added later.
> //Peter
>
Cheers,
Nico
--
-DISCLAIMER: an automatically appended disclaimer may follow. By posting-
-to a public e-mail mailing list I hereby grant permission to distribute-
-and copy this message.-
Visit our website at http://www.ubswarburg.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.
More information about the openssh-unix-dev
mailing list