php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kyle at videoegg dot com
New email:
PHP Version: OS:

 

 [2007-01-09 01:46 UTC] kyle at videoegg dot com
Description:
------------
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:
---------------
pid.php
<?php
$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");
fclose($handle);
?>

pid_output.php
<?php
$handle = fopen("pid.dat", "a");
fwrite($handle, "Child: " . getmypid() . "\n");
fclose($handle);
?>

Expected result:
----------------
Parent: 3480
Child: 3480


Actual result:
--------------
Parent: 3224
Child: 3480


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-09 17:58 UTC] nlopess@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 14:01:29 2024 UTC