From:             steven dot abarnett at gmail dot com
Operating system: Windows XP
PHP version:      5.2.9
PHP Bug Type:     Reproducible crash
Bug description:  PHP hangs when running proc_open()

Description:
------------
Unfortunately as far as I can tell, I am the only person having this
problem- which leads me to wonder if it's an issue with my PHP
configuration. Although I keep using default configuration, so I am at a
loss. I have tried installing PHP and Apache, I have tried in xampp, and I
have tried in WAMP. Every time after running the proc_open() command the
PHP script will wait for the process to close before reading the next line-
making reading or writing to any pipes impossible.

$fileDesc = array(
    0 => array("pipe", "r"), // STDIN
    1 => array("pipe", "w"), // STDOUT
    2 => array("pipe", "w") // STDERR
);
die("Got this far");
$handle = proc_open("C:/wherever/program.exe", $fileDesc, $pipes);
fwrite($pipes[0], "input");
fclose($pipes[0]);
proc_close($handle);

Displays "Got this far" and dies, as expected. However:

$fileDesc = array(
    0 => array("pipe", "r"), // STDIN
    1 => array("pipe", "w"), // STDOUT
    2 => array("pipe", "w") // STDERR
);
$handle = proc_open("C:/wherever/program.exe", $fileDesc, $pipes);
die("Got this far");
fwrite($pipes[0], "input");
fclose($pipes[0]);
proc_close($handle);

Will simply hang and seem to cease all function. The moment that I close
program.exe through task manager the script continues as if nothing were
wrong, dying with the output "Got this far". The input is never passed to
the program, although no errors are raised when I hit the proc_close()
line.

Reproduce code:
---------------
        $descriptors = array(
            0 => array("pipe", "r"), // STDIN. Used to feed input
            1 => array("pipe", "w"), // STDOUT. Used to read output
            2 => array("pipe", "w"), // STDERR. Used to read errors
            3 => array("pipe", "r") // We can feed the passphrase here
        );
        // Build the command line and start the process
        $cmd = '"C:/program files/gnu/gnupg/gpg.exe" --batch --no-verbose
--passphrase-fd 3 --output decrypted.zip --decrypt encrypted.zip.gpg';
        $gpg = proc_open( $cmd, $descriptors, $pipes);
        if(is_resource($gpg)) {
            // Push passphrase to custom pipe
            fwrite($pipes[3], $passphrase);
            fclose($pipes[3]);
            proc_close($gpg);
        }

Expected result:
----------------
Expected to find decrypted.zip in the same directory as the PHP script (a
decrypted version of encrypted.zip.gpg, which is located in the same
directory as the PHP script)

Actual result:
--------------
When localhost/test.php was run the webpage continued to load
indefinitely. I waited as long as 20 minutes. The PHP.ini file should stop
execution after 30 seconds. When gpg.exe was killed with task manager the
page loaded but the .zip file was never created.

-- 
Edit bug report at http://bugs.php.net/?id=47817&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47817&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47817&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47817&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47817&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47817&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47817&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47817&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47817&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47817&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47817&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47817&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47817&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47817&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47817&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47817&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47817&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47817&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47817&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47817&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47817&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47817&r=mysqlcfg

Reply via email to