Edit report at https://bugs.php.net/bug.php?id=51800&edit=1

 ID:                 51800
 Updated by:         paj...@php.net
 Reported by:        ph dot wolfer at googlemail dot com
 Summary:            proc_open on Windows hangs forever
 Status:             Assigned
 Type:               Bug
 Package:            Streams related
 Operating System:   Windows
 PHP Version:        *
 Assigned To:        ab
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2013-05-06 17:06:42] paj...@php.net

It is a php bug, same kind of call using standalone C code works fine.

------------------------------------------------------------------------
[2013-05-06 16:55:39] a...@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] a...@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.

------------------------------------------------------------------------
[2013-05-05 14:59:26] a...@php.net

Related To: Bug #64438

------------------------------------------------------------------------
[2013-03-16 03:15:06] hanskrentel at yahoo dot de

The problem with exactly 4097 bytes has just been reported here: 
https://bugs.php.net/bug.php?id=64438

It's a follow up to https://bugs.php.net/bug.php?id=60120 which is wrongly 
closed 
as resolved.

this and the many other issues show that the flaw is not fixed:

https://bugs.php.net/bug.php?id=51800
https://bugs.php.net/bug.php?id=60120
https://bugs.php.net/bug.php?id=64438

------------------------------------------------------------------------


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

Reply via email to