Edit report at https://bugs.php.net/bug.php?id=61492&edit=1
ID: 61492 Updated by: ahar...@php.net Reported by: spamik at yum dot pl Summary: flock for php 5.3.2 - regression -Status: Open +Status: Not a bug -Type: Feature/Change Request +Type: Bug -Package: *General Issues +Package: Streams related PHP Version: 5.3.10 Block user comment: N Private report: N New Comment: The manual sums this up: the behaviour was (intentionally) changed in 5.3.2, and isn't going to change again. Previous Comments: ------------------------------------------------------------------------ [2012-03-23 16:42:12] spamik at yum dot pl "The automatic unlocking when the file's resource handle is closed was removed. Unlocking now always has to be done manually." ------------------------------------------------------------------------ [2012-03-23 16:27:16] spamik at yum dot pl Description: ------------ http://www.php.net/manual/en/function.flock.php "On versions of PHP before 5.3.2, the lock is released also by fclose() (which is also called automatically when script finished)." This is huge regression. I've used with success file locking to check if another instance of file is already running putting code like this in front of the script or append_script $h55 = fopen($_SERVER['argv'][0],"r"); while(!flock($h55, LOCK_EX + LOCK_NB )) { echo "cant get lock, die\n"; die(); } or $h55 = fopen($_SERVER['argv'][0],"r"); while(!flock($h55, LOCK_EX + LOCK_NB )) { echo "cant get lock, waiting 10s\n"; sleep(10); } I've used it for scripts that had variable running time with a crontab. Now it is all impossible thanks to that change :( ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61492&edit=1