php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49095 proc_get_status['exitcode'] fails on win32
Submitted: 2009-07-29 08:29 UTC Modified: 2009-08-03 19:04 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: david dot gausmann at measx dot com Assigned: felipe (profile)
Status: Closed Package: Program Execution
PHP Version: 5.3.0 OS: win32 only - Windows XP SP3
Private report: No CVE-ID: None
 [2009-07-29 08:29 UTC] david dot gausmann at measx dot com
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-03 19:04 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2009-08-03 19:05 UTC] svn@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=286752
Log: - Fixed bug #49095 (proc_get_status['exitcode'] fails on win32)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 11:01:28 2024 UTC