From: david dot gausmann at measx dot com
Operating system: Windows XP SP3
PHP version: 5.3.0
PHP Bug Type: Program Execution
Bug description: proc_get_status['exitcode'] fails on win32
Description:
------------
I watch an subprocess with proc_get_status and the returned exit code is
never stored in the resulting array.
But the exit code from proc_close works!
Reproduce code:
---------------
--- file1.php ---
<?php
$arPipes = array();
$rProcess = proc_open('""C:\php\php.exe" "C:\php\file2.php""',
array(array('pipe', 'r'), array('pipe', 'w'),
array('pipe', 'w')), $arPipes);
if($rProcess !== false)
{
$nExitCode = -1;
do
{
while(!feof($arPipes[1]))
{
echo fread($arPipes[1], 1024);
flush();
}
$array = proc_get_status($rProcess);
if(!$array)
break;
if(!$array['running'] && $array['exitcode'] != -1)
$nExitCode = $array['exitcode'];
} while($array['running']);
fclose($arPipes[0]);
fclose($arPipes[1]);
fclose($arPipes[2]);
$array = proc_get_status($rProcess);
proc_close($rProcess);
echo "ExitCode: ", $nExitCode;
}
?>
--- file2.php ---
<?php
echo "This is just a stupid script!\r\n";
exit(1); //Script failed!
?>
Expected result:
----------------
This is just a stupid script!
ExitCode: 1
Actual result:
--------------
This is just a stupid script!
ExitCode: -1
--
Edit bug report at http://bugs.php.net/?id=49095&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=49095&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=49095&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=49095&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=49095&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=49095&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=49095&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=49095&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=49095&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=49095&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=49095&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=49095&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=49095&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=49095&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=49095&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49095&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49095&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=49095&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=49095&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=49095&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=49095&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=49095&r=mysqlcfg