note 79140 deleted from function.flock by nlopess

From: Date: Fri, 16 Nov 2007 11:28:26 +0000
Subject: note 79140 deleted from function.flock by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-132344@lists.php.net to get a copy of this message
Note Submitter: stonertom at gmail dot com Reason: in docs ---- I spent some time trying to find the correct way for having a non blocking lock. I've tested this in CLI and CGI PHP ver 5.2.4 <?php $i = 0; $fp = fopen('lockfile', 'w+'); while(!flock($fp, LOCK_EX | LOCK_NB)){ echo "\rSleep for: ".$i; sleep(1); $i++; } echo 'Lock aquired!'; sleep(60); fclose($fp); echo 'File closed!'; ?> Hope this demonstrates the function and syntax!

« previous php.notes (#132344) next »