File Locking in PHP: Do a LOCK_EX request "suspend" until ok
Posted: Mon Mar 17, 2008 12:51 pm
Look at the example below
flock($fp, LOCK_EX); // do an exclusive lock
fwrite($fp, "Write something here\n");
flock($fp, LOCK_UN);
What happens if an exclusive lock on the file is already being hold by another user? Does this script suspend until the other user leaves the lock?
If not, what should I do in order to wait until it's allowed to write to the file?
OS: Windows, Unix
flock($fp, LOCK_EX); // do an exclusive lock
fwrite($fp, "Write something here\n");
flock($fp, LOCK_UN);
What happens if an exclusive lock on the file is already being hold by another user? Does this script suspend until the other user leaves the lock?
If not, what should I do in order to wait until it's allowed to write to the file?
OS: Windows, Unix