ID:               41052
 Updated by:       [EMAIL PROTECTED]
 Reported By:      patrick dot pomme at rtl dot de
-Status:           Open
+Status:           Assigned
 Bug Type:         Program Execution
 Operating System: Windows XP
 PHP Version:      5.2.2RC1
-Assigned To:      
+Assigned To:      nlopess
 New Comment:

Nuno, please check if you can reproduce this.


Previous Comments:
------------------------------------------------------------------------

[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

Reply via email to