[Bug 52] ssh hangs on exit

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Thu Feb 23 08:44:12 EST 2006


http://bugzilla.mindrot.org/show_bug.cgi?id=52





------- Comment #20 from imaging at math.ualberta.ca  2006-02-23 08:44 -------
> It is essentially the same as the old, broken hang-on-exit fix that I
> mistakenly added around ~2.2.x except that it papers over the obvious dataloss
> race by only chopping off the read fd when it is a tty. It will still lose data
> on ttys.

That is in fact is the correct behaviour. Please check out how rsh and the
commercial ssh work: if the user types "exit" in a shell, all further I/O,
both reads and writes, are ignored. The rationale for this long-standing
convention is: if you want more I/O, don't type "exit"! 

One sensible use of this feature is to start up a program in the background
(which tees its output both to a log file and stdout) and then exit the shell
after viewing the initial output. But there are many other uses as well.
The current behaviour of openssh is annoying and unacceptable as a drop-in
replacement for rsh.

> (set -e ; while [ 1 ] ; do
>     ssh -qttp2222 linux-qemu "dd if=/dev/zero bs=256k count=1" |
>     wc -c ; done)

Because you tried to be clever and pretend to be an interactive tty
session, even though you are not. You want to say this instead:

(set -e ; while [ 1 ] ; do
     ssh -qp2222 linux-qemu "dd if=/dev/zero bs=256k count=1" |
    wc -c ; done)

There is no data loss with this command (or even if a single -t is given,
because ssh sensibly overrides this). So the question is, why do you need
to pretend to require a tty?

If there really is some sensible reason for forcing a tty allocation in
this context, then just pass a flag from ssh to sshd to indicate that
you have done so. It's a trivial modification, but I don't yet see the need.

> I recommend that packegers of OpenSSH do *not* apply this patch.

I highly recommend it; it's about time that this silly bug be fixed once
and for all. Let's move forward now...

Incidentally, to avoid confusion, please disregard the claim in Comment #16
that an earlier version of my hang-on-exit patch simply added an exit
delay. The exit delay business was a separate option that was added at the
request of another user. It has nothing at all to do with the hang-on-exit bug.
Since no else seems to have been interested in that feature, I stopped
maintaining that exit delay patch some time ago (although it would be easy
for someone to port my old openssh-sleep.patch to the current version).




------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.




More information about the openssh-bugs mailing list