Bug #39992 [Com]: proc_terminate() leaves children of child running
| From: | crrodriguez at opensuse dot org | Date: | Tue, 28 Feb 2023 22:16:02 +0000 |
| Subject: | Bug #39992 [Com]: proc_terminate() leaves children of child running | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-243823@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=39992&edit=1
ID: 39992
Comment by: crrodriguez at opensuse dot org
Reported by: nlopess@php.net
Summary: proc_terminate() leaves children of child running
Status: No Feedback
Type: Bug
Package: Program Execution
Operating System: linux
PHP Version: 6CVS-2006-12-30 (CVS)
Block user comment: N
Private report: N
New Comment:
I cannot reproduce this on linux with PHP 8.x git master.. even when run thousands of times through
a shell.. Im almost certainly missing something oe it was a bug in the shell...
Previous Comments:
------------------------------------------------------------------------
[2021-02-16 13:11:51] nikic@php.net
@machitgarha: To clarify, you're still seeing this issue when passing an *array* command to
proc_open()? It is expected that this doesn't work when passing a *string* command, because
those are invoked through a shell.
------------------------------------------------------------------------
[2021-02-16 12:23:29] machitgarha at outlook dot com
The bug is reproducible on 7.4.15, Fedora Workstation 33. Any fixes?
------------------------------------------------------------------------
[2020-03-15 04:22:04] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
------------------------------------------------------------------------
[2020-03-06 10:38:38] nikic@php.net
I believe this should be addressed in PHP 7.4 by writing:
$proc = proc_open(
['php', '-r', 'while(1){}'],
[2 => ['redirect', 1]],
$pipes);
var_dump(proc_terminate($proc));
This will not go through a shell, and as such the created process will be terminated directly.
Please let me know if there are still issues when going through the shell-free interface.
------------------------------------------------------------------------
[2016-03-06 02:29:59] php at mattwhitlock dot name
An easy workaround...
Instead of:
$proc = proc_open('cat', ...);
Use this:
$proc = proc_open('exec cat', ...);
It tells the shell to replace its own process with the command being executed rather than forking a
child process. This way you can properly kill the command using proc_terminate($proc).
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=39992
--
Edit this bug report at https://bugs.php.net/bug.php?id=39992&edit=1