|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-04-11 14:30 UTC] tony2001@php.net
[2007-04-21 11:47 UTC] nlopess@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 05:00:02 2025 UTC |
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