note 101701 added to function.flock

From: Date: Thu, 06 Jan 2011 01:13:04 +0000
Subject: note 101701 added to function.flock
Groups: php.notes 
Request: Send a blank email to php-notes+get-175475@lists.php.net to get a copy of this message
LOCK_NB seems to be checked and works fine in Windows, too, in PHP 5.3.3. For instance, try concurrently running two instances of the following script (via the CLI). The second prints "Didn't quite get the lock..." as expected, whereas w/o the LOCK_NB flag, it just hangs. <?php $x = fopen("flocktest.txt", "w"); if (flock($x, LOCK_EX|LOCK_NB)) { print "No problems, I got the lock, now I'm going to sit on it."; while (true) sleep(5); } else { print "Didn't quite get the lock. Quitting now. Good night."; } fclose($x); ---- Server IP: 69.147.83.197 Probable Submitter: 173.164.72.169 ---- Manual Page -- http://www.php.net/manual/en/function.flock.php Edit -- https://master.php.net/note/edit/101701 Del: integrated -- https://master.php.net/note/delete/101701/integrated Del: useless -- https://master.php.net/note/delete/101701/useless Del: bad code -- https://master.php.net/note/delete/101701/bad+code Del: spam -- https://master.php.net/note/delete/101701/spam Del: non-english -- https://master.php.net/note/delete/101701/non-english Del: in docs -- https://master.php.net/note/delete/101701/in+docs Del: other reasons-- https://master.php.net/note/delete/101701 Reject -- https://master.php.net/note/reject/101701 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175475) next »