SSH connection hanging on logout

John Bowman bowman at math.ualberta.ca
Thu May 17 06:32:14 EST 2001


> i think that shutdown should only be allowed if c->istate ==
> CHAN_INPUT_CLOSED;

No, this will cause openssh to hang under interactive use. When the shell
exits, no more data should be read. Even if you execute a backround process
noninteractively, like in Damien's example

ssh host "(sleep 20 ; dd if=/dev/zero bs=1024 count=100 | wc -c)&"

it seems reasonable to me that the sleep 20 should be started in the
background and then the shell should immediately exit. The output from dd
will be discarded. (If you don't like this then don't put the dd in the
background.) This is the same behaviour as in the commercial version 
of ssh, which OpenSSH is trying to emulate. See the previous postings about
background processes and interactive shells.

For noninteractive usage, like in the above example, rsh actually *does* keep
the connection open until the backgrounded process finishes. If you really
want OpenSSH to emulate rsh and not SSH then I suppose one could modify the
patch so that it only applies to interactive sessions. Note that under
interactive usage neither rsh or SSH hang: 

ssh host
sleep 20&
exit

The only exception, for both SSH and (the patched) OpenSsh-2.9p1, should
be for X applications. In this case, the ssh connection has to be kept open
because it is needed to forward the X traffic.

So a call to shutdown is really needed. But the data that has already been
read should be sent on across the channel in order to avoid data loss
from a command like

while [ 1 ]; do ssh host "dd if=/dev/zero bs=8192 count=10" | wc -c; done

Actually, chan_read_failed_12 should have done this, but it sets 
c->istate = CHAN_INPUT_WAIT_DRAIN and there appears to be a bug in the
handling of this state that causes the previously read data not be sent
across the channel. My patch works around this and also implements a proper
handling of X applications.

> moreover, i'm still waiting for feedback on what rlogind does on
> these systems.
See above.

-- John Bowman

University of Alberta
http://www.math.ualberta.ca/~bowman




More information about the openssh-unix-dev mailing list