Edit report at https://bugs.php.net/bug.php?id=51800&edit=1
ID: 51800
Updated by: ab@php.net
Reported by: ph dot wolfer at googlemail dot com
Summary: proc_open on Windows hangs forever
-Status: Assigned
+Status: Closed
Type: Bug
Package: Streams related
Operating System: Windows
PHP Version: *
Assigned To: ab
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0c982798e01e5a48765aa5352f96066e77e36efd
Log: Fixed bug #51800 proc_open on Windows hangs forever
Previous Comments:
------------------------------------------------------------------------
[2013-10-16 18:42:11] imprec at gmail dot com
Hello,
what's the state on this bug? It's quite annoying. Using file handles as a workaround does
not work very well on windows (see https://bugs.php.net/bug.php?id=65650).
Is there any plan to solve it? I'd be glad to contribute, but my skills are pretty bad at this
level :/
------------------------------------------------------------------------
[2013-05-08 06:33:55] pajoye@php.net
A good summary of the problem we are experiencing here:
http://blogs.msdn.com/b/oldnewthing/archive/2011/07/07/10183884.aspx
The fix is not that easy. Either using overlapped/async IO or threads.
------------------------------------------------------------------------
[2013-05-06 17:06:42] pajoye@php.net
It is a php bug, same kind of call using standalone C code works fine.
------------------------------------------------------------------------
[2013-05-06 16:55:39] ab@php.net
Could you please try this slightly modified php snippet?
============ START process.php ===============
<?php
$how_much = 10000;
$data0 = str_repeat("a", $how_much);
$data1 = str_repeat("b", $how_much);
fwrite(STDOUT, $data0);
fwrite(STDERR, $data1);
exit(0);
============ END process.php ===============
============ START 51800.php ===============
<?php
$cmd = "\"C:/php-sdk/php55/vc11/x86/php-src/Debug/php.exe\" process.php";
$status;
$stdout = "";
$stderr = "";
$pipes = array();
$descriptors = array(
0 => array("pipe", "rb"), // stdin
1 => array("pipe", "wb"), // stdout
2 => array("pipe", "wb") // stderr
);
$process = proc_open($cmd, $descriptors, $pipes);
if (is_resource($process))
{
fclose($pipes[0]);
while (!feof($pipes[1]) || !feof($pipes[2])) {
$stdout .= fread($pipes[1], 1024);
$stderr .= fread($pipes[2], 1024);
}
fclose($pipes[1]);
fclose($pipes[2]);
$status = proc_close($process);
}
print_r(array(
"status" => $status,
"stdout" => $stdout,
"stderr" => $stderr,
));
============ END 51800.php ===============
This bug might be pretty much not a php bug, but the consequence of the pipe
nature.
------------------------------------------------------------------------
[2013-05-06 07:47:53] ab@php.net
It hangs at http://lxr.php.net/xref/PHP_5_5/main/streams/plain_wrapper.c#348
, the
read call doesn't return at some point. Setting the pipe mode to wb tells no
difference. But I guess the cause is somewhere in the upper levels, may be in the
descriptor options. So continuing to debug.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=51800
--
Edit this bug report at https://bugs.php.net/bug.php?id=51800&edit=1