Bug #69014 [NEW]: proc_close and proc_get_status returns NULL. Zombies remain in process-list

From: Date: Sun, 08 Feb 2015 15:37:19 +0000
Subject: Bug #69014 [NEW]: proc_close and proc_get_status returns NULL. Zombies remain in process-list
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190533@lists.php.net to get a copy of this message
From:             f0o at devilcode dot org
Operating system: Gentoo 2.2, Debian Jessie
PHP version:      5.5.21
Package:          Program Execution
Bug Type:         Bug
Bug description:proc_close and proc_get_status returns NULL. Zombies remain in process-list

Description:
------------
'proc_get_status' and 'proc_close' return 'NULL' and leave the process
as defunct/Zombie in the process-list.
The process has no open files and is verified to be terminated in
execution.

PHP Versions 5.5.21 and 5.6.5 are affected.
PHP Versions 5.4.37 is NOT affected.

The bug was noticed under Gentoo 2.2 and verified under Debian Jessie.

Gentoo has been used to isolate the affected versions as it guarantees
an equal build-environment for all php-installations and allows to
'hotswap' the versions at any given time.

All tests have been conducted with PHP-FPM under Nginx.
Version of Nginx has no influence on the bug.

Test script:
---------------
<?php
function pipe_open(&$process, &$pipes) {
  $command = "/bin/date +%s";
  $descriptorspec = array(
     0 => array("pipe", "r"),  // stdin is a pipe that the child will
read from
     1 => array("pipe", "w"),  // stdout is a pipe that the child will
write to
     2 => array("pipe", "w")   // stderr is a pipe that the child will
write to
  );
  $cwd = '/';
  $env = array();
  $process = proc_open($command, $descriptorspec, $pipes, $cwd, $env);
var_dump("Proc:");
var_dump($process);
var_dump("Status:");
var_dump(proc_get_status($process));
  stream_set_blocking($pipes[1], 0);
  stream_set_blocking($pipes[2], 0);

  if( is_resource($process) ) {
    return true;
  }
}
function pipe_close($process, &$pipes) {
  fclose($pipes[0]);
  fclose($pipes[1]);
  fclose($pipes[2]);
var_dump("Status:");
var_dump(proc_get_status($process));
  $return_value = proc_close($process);
var_dump("RetVal:");
var_dump($return_value);
var_dump("Proc:");
var_dump($process);
  return $return_value;
}
function test($param) {
  pipe_open($process, $pipes);
  if( is_resource($process) ) {
    fwrite($pipes[0], $param);
    fclose($pipes[0]);
    while( strlen($line) < 1 ) {
      $line = fgets($pipes[1],1024);
      $data .= $line;
    }
    $return_value = pipe_close($process, $pipes);
    return $data;
  } else {
    return 0;
  }
}
var_dump(test(""));
?>

Expected result:
----------------
string(5) "Proc:"
resource(5) of type (process)
string(7) "Status:"
array(8) {
  ["command"]=>
  string(13) "/bin/date +%s"
  ["pid"]=>
  int(30731)
  ["running"]=>
  bool(true)
  ["signaled"]=>
  bool(false)
  ["stopped"]=>
  bool(false)
  ["exitcode"]=>
  int(-1)
  ["termsig"]=>
  int(0)
  ["stopsig"]=>
  int(0)
}
string(7) "Status:"
array(8) {
  ["command"]=>
  string(13) "/bin/date +%s"
  ["pid"]=>
  int(30731)
  ["running"]=>
  bool(true)
  ["signaled"]=>
  bool(false)
  ["stopped"]=>
  bool(false)
  ["exitcode"]=>
  int(-1)
  ["termsig"]=>
  int(0)
  ["stopsig"]=>
  int(0)
}
string(7) "RetVal:"
int(0)
string(5) "Proc:"
resource(5) of type (Unknown)
string(11) "1423408318
"


Actual result:
--------------
string(5) "Proc:"
resource(5) of type (process)
string(7) "Status:"
NULL
string(7) "Status:"
NULL
string(7) "RetVal:"
NULL
string(5) "Proc:"
resource(5) of type (process)
string(11) "1423408318
"

-- 
Edit bug report at https://bugs.php.net/bug.php?id=69014&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=69014&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=69014&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=69014&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=69014&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=69014&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=69014&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=69014&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=69014&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=69014&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=69014&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=69014&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=69014&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=69014&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69014&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=69014&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=69014&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=69014&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69014&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=69014&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=69014&r=mysqlcfg



Thread (7 messages)

« previous php.bugs (#190533) next »