|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40070 proc_get_status - wrong PID
Submitted: 2007-01-09 01:46 UTC Modified: 2007-01-09 17:58 UTC
From: kyle at videoegg dot com Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 5.2.1RC2 OS: Windows XP SP2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: kyle at videoegg dot com
New email:
PHP Version: OS:


 [2007-01-09 01:46 UTC] kyle at videoegg dot com
This is identical to Bug #38542

There still seems to be an issue with this. I have upgraded my PHP installation to "PHP 5.2.1RC3-dev (cli) (built: Jan  9 2007 00:24:29)" on Windows and I am getting the wrong PID returned. 

proc_get_status returns 2976 for the PID while the script that is being executed sees its PID as 3768 from getmypid(). 

Additionally, "tasklist" from the command line returns:

php.exe        3768 Console    0  9,084 K

Reproduce code:
$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

$resource = proc_open('php -f pid_output.php', $descriptorspec, $pipes);

$stats = proc_get_status($resource);

$handle = fopen("pid.dat", "a");
fwrite($handle, "Parent: " . $stats['pid'] . "\n");

$handle = fopen("pid.dat", "a");
fwrite($handle, "Child: " . getmypid() . "\n");

Expected result:
Parent: 3480
Child: 3480

Actual result:
Parent: 3224
Child: 3480


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-09 17:58 UTC]
it returns the PID of cmd.exe, as in the linux implementation. However if you set the last parameter as array('bypass_shell' => true), you'll get the PID of the program, because you are bypassing the shell.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jul 06 21:01:04 2020 UTC