php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41052 proc_get_status still returns wrong PID (-> closed bug 38542)!
Submitted: 2007-04-11 12:40 UTC Modified: 2007-04-21 11:47 UTC
From: patrick dot pomme at rtl dot de Assigned: nlopess (profile)
Status: Not a bug Package: Program Execution
PHP Version: 5.2.2RC1 OS: Windows XP
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: patrick dot pomme at rtl dot de
New email:
PHP Version: OS:

 

 [2007-04-11 12:40 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-11 14:30 UTC] tony2001@php.net
Nuno, please check if you can reproduce this.
 [2007-04-21 11:47 UTC] nlopess@php.net
proc_get_status() returns the PID of the shell (cmd) instead of the program. This matches the unix bahaviour.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 14:01:29 2024 UTC