|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-11-18 04:22 UTC] requinix@php.net
-Summary: Add ability to prevent hanles inheritance
+Summary: Add ability to prevent handles inheritance in popen
-Package: *General Issues
+Package: Filesystem function related
[2015-11-18 04:22 UTC] requinix@php.net
[2015-11-18 05:14 UTC] speller at yandex dot ru
[2017-10-09 09:41 UTC] kelunik@php.net
-Summary: Add ability to prevent handles
inheritance in popen
+Summary: Add ability to prevent handles
inheritance in popen / proc_open
-Package: Filesystem function related
+Package: Program Execution
-Operating System: windows
+Operating System: Irrelevant
-PHP Version: 5.6.15
+PHP Version: 7.1.10
[2017-10-09 09:41 UTC] kelunik@php.net
[2017-10-10 08:43 UTC] mike@php.net
[2017-10-10 10:03 UTC] speller at yandex dot ru
[2017-10-10 10:48 UTC] kelunik@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 14:00:01 2025 UTC |
Description: ------------ Currently, any child process started from PHP using popen(), proc_open() or exec() etc. will inherit opened file handles. This is caused by TRUE value of the bInheritHandles parameter of the CreateProcess WinAPI function. This lead to the following issue. Example pseudocode: strater.php <? $f = fopen('file.txt'); popen('php worker.php'); fclose('file.txt'); unlink('file.txt'); ?> worker.php <? sleep(600); ?> If you will try to run these scripts you will get the exception on unlink('file.txt') line saying you don't have such permissions to remove the file. Because the opened file handle was inherited by the child process 'php worker.php' and even if you fclose() the starter's file handle the file can not be deleted while there is any other handle referenced to it in any other process in the system. So in this case the worker process do nothing in its code to lock the file, but system internals do it and the script can not prevent it. So I suggest to add an ability to set the bInheritHandles flag to FALSE when creating child processes to prevent the issue when child process keeps file handles implicitly. Expected result: ---------------- The file.txt shold be deleted by the unlink() function. Actual result: -------------- unlink() function fail to delete file.txt with message of lack permissions.