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

Dan Grillo Dan_Grillo at
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,


----- Begin forwarded message:

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


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  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 ./
Pid is xxxx
> exit
[hangs five seconds!]

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


#!/usr/bin/perl -w

use strict;


unless (fork()) {

  print "pid $$\n";
  if (@ARGV > 0) {

  system("sleep 5");

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

More information about the openssh-unix-dev mailing list