php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64465 proc_get_status update time when using proc_terminate
Submitted: 2013-03-20 15:32 UTC Modified: 2013-03-20 19:20 UTC
From: andrey dot kalinovsky at gmail dot com Assigned:
Status: Not a bug Package: Program Execution
PHP Version: Irrelevant OS: OSX, Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrey dot kalinovsky at gmail dot com
New email:
PHP Version: OS:

 

 [2013-03-20 15:32 UTC] andrey dot kalinovsky at gmail dot com
Description:
------------
After proc_terminate has been called, there is a time during which proc_get_status 
will still describe the child process as running. 

Test script:
---------------
<?php

$descriptorspec = array(
                        0 => array("pipe", "r"),
                        1 => array("pipe", "w"),
                        2 => array("pipe", "w")
                        );

$process = proc_open("sleep 20", $descriptorspec, $pipes);
var_dump(proc_get_status($process));
proc_terminate($process);
var_dump(proc_get_status($process));
sleep(1);
var_dump(proc_get_status($process));

Expected result:
----------------
array(8) {
  'command' =>
  string(8) "sleep 20"
  'pid' =>
  int(14027)
  'running' =>
  bool(true)
  'signaled' =>
  bool(false)
  'stopped' =>
  bool(false)
  'exitcode' =>
  int(-1)
  'termsig' =>
  int(0)
  'stopsig' =>
  int(0)
}
array(8) {
  'command' =>
  string(8) "sleep 20"
  'pid' =>
  int(14027)
  'running' =>
  bool(false)
  'signaled' =>
  bool(true)
  'stopped' =>
  bool(false)
  'exitcode' =>
  int(-1)
  'termsig' =>
  int(15)
  'stopsig' =>
  int(0)
}
array(8) {
  'command' =>
  string(8) "sleep 20"
  'pid' =>
  int(14027)
  'running' =>
  bool(false)
  'signaled' =>
  bool(true)
  'stopped' =>
  bool(false)
  'exitcode' =>
  int(-1)
  'termsig' =>
  int(15)
  'stopsig' =>
  int(0)
}

Actual result:
--------------
array(8) {
  'command' =>
  string(8) "sleep 20"
  'pid' =>
  int(14027)
  'running' =>
  bool(true)
  'signaled' =>
  bool(false)
  'stopped' =>
  bool(false)
  'exitcode' =>
  int(-1)
  'termsig' =>
  int(0)
  'stopsig' =>
  int(0)
}
array(8) {
  'command' =>
  string(8) "sleep 20"
  'pid' =>
  int(14027)
  'running' =>
  bool(true)
  'signaled' =>
  bool(false)
  'stopped' =>
  bool(false)
  'exitcode' =>
  int(-1)
  'termsig' =>
  int(0)
  'stopsig' =>
  int(0)
}
array(8) {
  'command' =>
  string(8) "sleep 20"
  'pid' =>
  int(14027)
  'running' =>
  bool(false)
  'signaled' =>
  bool(true)
  'stopped' =>
  bool(false)
  'exitcode' =>
  int(-1)
  'termsig' =>
  int(15)
  'stopsig' =>
  int(0)
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-20 15:56 UTC] andrey dot kalinovsky at gmail dot com
This is a big issue when working with libev eventloop, since it's about handling 
child processes asynchronously. So, I can't just let the sleep(1) here, the 
solution must be asynchronous...
 [2013-03-20 19:16 UTC] aharvey@php.net
-Status: Open +Status: Not a bug
 [2013-03-20 19:16 UTC] aharvey@php.net
proc_terminate() is documented as being asynchronous in the manual — all it 
really does internally is to call kill(), which simply sends a signal. 
pcntl_waitpid() is presumably what you need to call after proc_terminate(), if 
you don't want to poll with proc_get_status().
 [2013-03-20 19:20 UTC] andrey dot kalinovsky at gmail dot com
Thank you for your input. But pcntl_waitpid is blocking, so I cannot use it. Are 
there any other ways by any chance ?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 14:01:32 2025 UTC