#30743 [NEW]: proc_open() / proc_close() leak handles on Windows XP

From: Date: Wed, 10 Nov 2004 08:43:29 +0000
Subject: #30743 [NEW]: proc_open() / proc_close() leak handles on Windows XP
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-68884@lists.php.net to get a copy of this message
From:             ilya77 at gmail dot com
Operating system: Windows XP
PHP version:      5.0.2
PHP Bug Type:     Program Execution
Bug description:  proc_open() / proc_close() leak handles on Windows XP

Description:
------------
I have a scheduler script, which constantly runs in the background,
invokes processes, and pipes their output back to stdout.

It seems that proc_open() or proc_close() call leaks handles on Windows
platform (I'm running PHP 5.0.2).

In the example code, the handles count would increment by 1 each time
invoke() is called, in other places I saw similar code leak 4 handles at
once during each iteration.


Reproduce code:
---------------
while(1)
{
	echo("---\n");
	invoke();
	sleep(5);
}

function invoke()
{
	$commandLine = "echo hello";

	$fileDescriptors = array(
					1 => array("pipe", "w"),
					2 => array("pipe", "w")
				);

	$pipes = array();

	$processHandle	= proc_open($commandLine,
                                  $fileDescriptors, $pipes);

	if (is_resource($processHandle))
	{
		foreach($pipes as $pipeID => $pipeHandle)
			fclose($pipeHandle);

		proc_close($processHandle);
	}
}


Expected result:
----------------
I expected the handle count to increment by X, and decrement by X after
the process completes.
(where it's logical to assume that X = number of pipes + 1 for the child
process handle)


Actual result:
--------------
In fact, the handles count (in windows task manager) for the php.exe
process running the script incremented by 1 each time invoke() in the
example code was executed.


-- 
Edit bug report at http://bugs.php.net/?id=30743&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30743&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30743&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30743&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30743&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30743&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30743&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30743&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30743&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30743&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30743&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30743&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30743&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30743&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30743&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30743&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30743&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30743&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30743&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30743&r=mysqlcfg


Thread (3 messages)

« previous php.bugs (#68884) next »