|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8519 closedir() does not close directory handle until script terminates
Submitted: 2001-01-02 13:28 UTC Modified: 2001-01-02 20:01 UTC
From: kat at unleashed dot org Assigned:
Status: Closed Package: Directory function related
PHP Version: 4.0.3pl1 OS: Windows NT 4.0, Windows 2000 Ser
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: kat at unleashed dot org
New email:
PHP Version: OS:


 [2001-01-02 13:28 UTC] kat at unleashed dot org
The below script will generate a "permission denied" error when trying to rmdir the specified directory. sleep() does not do any good (in helping me delete the dir), nor does putting the reading of the directory into a function. After I moved the rmdir into a separate script it did not generate an error. It makes no difference whether it's forward or backward slashes in the path.

This happens only after using the opendir/readdir/closedir sequence. I have not tested further to see if readdir may be the issue.

This is a stock 4.03pl1 php, running as an apache module.

My Test script:

	$dirName = "c:/temp/";

	function checkDir()
		global $dirName;

		$dirHandle = opendir($dirName);

		while($fileName = readdir($dirHandle))
			print $fileName."\n";


	print "Making directory\n";
	mkdir($dirName, 0777);


	print "Removing directory\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-02 20:01 UTC]
This is fixed in PHP 4.0.4.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jul 28 06:01:23 2021 UTC