flock() - how does this baby work?
| From: | August Zajonc | Date: | Sun, 28 May 2000 16:25:02 +0000 |
| Subject: | flock() - how does this baby work? | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-15862@lists.php.net to get a copy of this message | ||
Looking to lock a file. I acquire the lock twice here, and both times it's
exclusive. Am I missing something here? Does the second flock have to be on
a different file handle? Creating $fp2 pointing to the same file and then
trying to acquire an exclusive lock seemed to block, even with operation set
to 6.
<?
$fp = fopen("test", "w+");
if(flock($fp, 2))
echo "locked";
if(flock($fp, 2))
echo "locked";
?>
Output is two locked statements instead of the one I expected.
August