#41052 [Asn->Bgs]: proc_get_status still returns wrong PID (-> closed bug 38542)!
| From: | nlopess@php.net | Date: | Sat, 21 Apr 2007 11:47:24 +0000 |
| Subject: | #41052 [Asn->Bgs]: proc_get_status still returns wrong PID (-> closed bug 38542)! | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-111766@lists.php.net to get a copy of this message | ||
ID: 41052
Updated by: nlopess@php.net
Reported By: patrick dot pomme at rtl dot de
-Status: Assigned
+Status: Bogus
Bug Type: Program Execution
Operating System: Windows XP
PHP Version: 5.2.2RC1
Assigned To: nlopess
New Comment:
proc_get_status() returns the PID of the shell (cmd) instead of the
program. This matches the unix bahaviour.
Previous Comments:
------------------------------------------------------------------------
[2007-04-11 14:30:29] tony2001@php.net
Nuno, please check if you can reproduce this.
------------------------------------------------------------------------
[2007-04-11 12:40:02] patrick dot pomme at rtl dot de
Description:
------------
Under Windows XP and server 2003, proc_get_status returns a wrong PID.
While executing a system command I wanted to know its PID to be able to
close it after a defined timeout
Reproduce code:
---------------
$cmd = "ping -t video-jobcoder";
$descriptorspec = array(
0 => array("file", "stdin.txt", "a"), // stdin is a pipe that
the
child will read from
1 => array("file", "stdout.txt", "a"), // stdout is a pipe that
the
child will write to
2 => array("file", "stderr.txt", "a") // stderr is a file to
write
to
);
$process = proc_open($cmd, $descriptorspec, $pipes);
$pinfo = proc_get_status($process);
print_r($pinfo);
$timeout = 5;
while(@proc_get_status($process)){
echo "$timeout..";
sleep(1);
$timeout--;
if($timeout == 0) {
echo "\r\nTimeout! Killing process with PID ".$pinfo[pid]."!";
exec($path_to_pskill."pskill -t ".$pinfo[pid]." 2>nul",
$res_pskill);
for ($i=count($res_pskill)-3; $i<count($res_pskill); $i++) echo
$res_pskill[$i]."\r\n";
proc_terminate($process);
}
}
Expected result:
----------------
$pinfo[pid] should contain the PID of the ping process
proc_terminate should close it
Actual result:
--------------
$pinfo[pid] returns a wrong number
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41052&edit=1