OpenSSH_2.5.1p2 hang on log out due to unclosed file handles in forked process

Dan Grillo Dan_Grillo at grillo.net
Sat Mar 17 16:41:00 EST 2001



OpenSSH folks,

We're run into a problem with OpenSSH_2.5.1p2 servers that
we didn't see before, and I can't reproduce with OpenSSH_2.3.0p1
servers.  (OpenSSH_2.3.0p1 seems to work correctly)
We're seeing this bug on Solaris 2.7 and on Linux 2.2.15 machines.

Basically, if you log into a machine, fork a process that leaves
stdout, stderr, or stdin open, and try to log out of that machine,
your logout will block.

Included is a great description of the bug from another thread
and the a sample program.

Does anyone know what's going on here?

I'm not subscribed, so direct mail would be great.

Thanks for any ideas,

			--Dan



----- Begin forwarded message:

From: Steven Ihde <sihde at ariba.com>
Subject: Re: openssh hang
To: Daniel Sully <dsully at ariba.com>
Date: Fri, 16 Mar 2001 15:15:23 -0800


Dan,

Yes, I noticed it as soon as we upgraded to OpenSSH.  This might be a
red herring, but....  If you fork a process and it doesn't close
stdin, stdout, and stderr, OpenSSH will hang at logout until that
process DOES close all three.  This was not the case with old ssh, nor
with telnet.  

Put the attached script in your home directory (as foo.pl).  If run
with no args, it forks a proc that sleeps 5 seconds.  If you supply an
arg (anything) it will fork, close stdin, stdout, and stderr, and THEN
sleep 5 seconds.  You will see the following:

> ssh any-host-running-openssh ./foo.pl
Pid is xxxx
> exit
[hangs five seconds!]

> ssh any-host-running-openssh ./foo.pl foo
Pid is xxxx
> exit
[doesn't hang!]

-Steve


#!/usr/bin/perl -w

use strict;

$|=1;

unless (fork()) {

  print "pid $$\n";
  if (@ARGV > 0) {
      close(STDIN);
      close(STDOUT);
      close(STDERR);
  }

  system("sleep 5");
}



----- End forwarded message
--
  Dan Grillo   dan at grillo.net  (650) 917-0685  fax (209)315-7970





More information about the openssh-unix-dev mailing list