|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-01-28 08:44 UTC] jani@php.net
[2009-01-28 15:13 UTC] murphyk at yahoo-inc dot com
[2009-01-29 21:34 UTC] bfrance@php.net
[2010-05-21 15:51 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 08:00:01 2025 UTC |
Description: ------------ The behavior of flock()ed files across forks appears to have changed between php 4.4.8 and php 5.2.8. Previously, children would inherit filehandles from their parent, and would close() their copies of the filehandles on exit, but this would not clear flock()s on the files locked in the parent. Now, it appears that if any child exits(), this will clear flock()s on any filehandles inherited from the parent. Reproduce code: --------------- <?php $fp = fopen("/tmp/lock.txt", "w+"); if (flock($fp, LOCK_EX + LOCK_NB )) { print "Got lock.\n"; } else { print "Couldn't lock the file.\n"; exit(); } $pid = pcntl_fork(); if ($pid) { pcntl_waitpid($pid,$status); } else { exit(); } sleep(100); ?> Expected result: ---------------- $ php flock.php & [1] 22054 $ Got lock. $ php flock.php Couldn't lock the file. Actual result: -------------- $php flock.php & [1] 31085 $Got lock. $php flock.php Got lock.