Req #70932 [NEW]: Add ability to prevent hanles inheritance

From: Date: Wed, 18 Nov 2015 03:14:50 +0000
Subject: Req #70932 [NEW]: Add ability to prevent hanles inheritance
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197308@lists.php.net to get a copy of this message
From: speller at yandex dot ru Operating system: windows PHP version: 5.6.15 Package: *General Issues Bug Type: Feature/Change Request Bug description:Add ability to prevent hanles inheritance 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. -- Edit bug report at https://bugs.php.net/bug.php?id=70932&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70932&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70932&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70932&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70932&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70932&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70932&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70932&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70932&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70932&r=support Expected behavior: https://bugs.php.net/fix.php?id=70932&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70932&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70932&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70932&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70932&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70932&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70932&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70932&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70932&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70932&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70932&r=mysqlcfg

« previous php.bugs (#197308) next »