|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61297 readdir hangs when connected to Solaris
Submitted: 2012-03-06 00:33 UTC Modified: 2012-06-20 14:59 UTC
From: tjg at soe dot ucsc dot edu Assigned:
Status: Not a bug Package: ssh2 (PECL)
PHP Version: 5.3.10 OS: FreeBSD => Solaris
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: tjg at soe dot ucsc dot edu
New email:
PHP Version: OS:


 [2012-03-06 00:33 UTC] tjg at soe dot ucsc dot edu

I am connecting to a Solaris file server and running a readdir (see the test script for more information).

The script iterates through everything in the folder, and then on the last iteration, where readdir() should return false, it just hangs.  The process is killable via ctrl-C but it never completes that loop.  The folder in question has a few hundred files, but other systems are able to list the files in that folder without a problem.  I've tried two different PHP clients: FreeBSD (PHP 5.3.10) clients and CentOS (5.1.6) and both behave the same way.  Other SFTP applications do not seem to have this problem.  For example, if I connect using the FreeBSD SFTP command-line client, it works as expected.

Test script:
$folder = opendir("ssh2.sftp://" . $sftp . $folder_name);

if (!$folder) {
  echo "ERROR: Could not list folder contents on " . $server_name . "!\n";


while (($file_name = readdir($folder)) !== false) {
  echo $file_name . "\n";

Expected result:
It should print out a list of the files in the remote folder.

Actual result:
The script hangs on what should be the last readdir().


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-16 09:45 UTC]
I sent tjg an email on how to proceed to solve this bug, as I don't have a 
Solaris server to debug this.
 [2012-06-18 15:33 UTC] tjg at soe dot ucsc dot edu
I am very sorry that I didn't resolve this ticket earlier.  I actually totally forgot about it.  Patching SunOS actually appears to have fixed this problem, so my guess is that it was a problem with their SSH server and not the PECL module.  Sorry about not reporting that sooner!  :\
 [2012-06-20 14:59 UTC]
-Status: Open +Status: Not a bug
 [2012-06-20 14:59 UTC]
Happy this is solved!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 28 17:01:31 2024 UTC