SSH connection hanging on logout

John Bowman bowman at math.ualberta.ca
Mon May 21 10:47:48 EST 2001


> From: Markus Friedl <markus.friedl at informatik.uni-erlangen.de>

> ok, so just fyi:
> 	dd if=/bsd bs=65536 count=2
> gets truncated on my openbsd development system.
> 
> you have to get into this situtation:
> 
> 	shell writes last block into pipe to sshd process.
> 	shell dies
> 	not all data has been read from the pipe.
> 
> i can trigger this with
> 	dd if=/bsd bs=65536 count=2
> 
> the figures should be different for other systems, but i think
> all systems will show this problem.

It depends on how pipes are implemented. The scenario you describe
doesn't happen under Linux; the shell doesn't exit until all of the data
has been read from the pipe. I suspect these differences in the way the shell
and pipes interact are the underlying reason why you don't see the
hang-on-exit bug at all on OpenBSD.

Tweaking the parameters in your test doesn't make any difference on Linux,
as demonstrated by the output of the script below. Changing localhost
to another host (be sure to compare identical files) or working under
different load average conditions does not affect the results.

The patch has been subjected to exhaustive testing. Unless someone reports
a case where it fails before the next release, please go ahead and include
it in the next Linux version of OpenSSH. (If you don't like the -S option
for some reason, you can always remove it and the sleep config option).

#!/bin/sh
size=$1
incr=$2
count=$3
delay=$4
checksum=
answer=
while [ "$checksum" = "$answer" ]
do
checksum=`ssh localhost dd if=/usr/local/netscape/netscape bs=$size count=$count | ( sleep $delay ; md5sum )`
answer=`dd if=/usr/local/netscape/netscape bs=$size count=$count | md5sum`
echo $size $count $delay $checksum $answer
size=$[ $size + $incr ]
done
echo CHECKSUM MISMATCH! 


The output of the tests is available at

http://www.math.ualberta.ca/imaging/snfs/hang-on-exit.test

-- John Bowman

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



More information about the openssh-unix-dev mailing list