Req #70932 [Com]: Add ability to prevent handles inheritance in popen / proc_open
| From: | kelunik@php.net | Date: | Tue, 10 Oct 2017 10:48:29 +0000 |
| Subject: | Req #70932 [Com]: Add ability to prevent handles inheritance in popen / proc_open | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211605@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70932&edit=1
ID: 70932
Comment by: kelunik@php.net
Reported by: speller at yandex dot ru
Summary: Add ability to prevent handles inheritance in popen
/ proc_open
Status: Open
Type: Feature/Change Request
Package: Program Execution
Operating System: Irrelevant
PHP Version: 7.1.10
Block user comment: N
Private report: N
New Comment:
The 'e' flag doesn't work on Windows, works only for fopen and I don't know any
library that uses it, so it doesn't really help.
I think the default should be changed to use O_CLOEXEC. Another alternative is to just close all
descriptors after the fork and before the exec that are not 0|1|2, at least with an option such as
"inherit_handles" => false.
On Windows it's trivial to implement "inherit_handles" => false, because it's
explicitly set there.
Previous Comments:
------------------------------------------------------------------------
[2017-10-10 10:03:03] speller at yandex dot ru
Will the 'e' fopen flag work under Windows?
------------------------------------------------------------------------
[2017-10-10 08:43:59] mike@php.net
See the 'e' mode flag for fopen.
------------------------------------------------------------------------
[2017-10-09 09:41:28] kelunik@php.net
This issue appears on both Windows and Unix as it seems. It causes https://github.com/amphp/aerys/issues/192 and
without a fix it's not possible to launch long-running child processes in any long running PHP
script like an app server.
------------------------------------------------------------------------
[2015-11-18 05:14:49] speller at yandex dot ru
I tried the proc_open() function but it has the same issue - file handles are inherited from the
parent process. So all files opened in the parent process at the time of the child process starting
remain opened all the time while child process is running. This is an important issue if child
process should work much longer than parent process.
------------------------------------------------------------------------
[2015-11-18 04:22:40] requinix@php.net
popen is supposed to behave like a fork. The Windows behavior mirrors the Unix behavior.
http://linux.die.net/man/3/popen
Maybe you should be using proc_open?
------------------------------------------------------------------------
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=70932
--
Edit this bug report at https://bugs.php.net/bug.php?id=70932&edit=1