RE: [PHP] flock(), fclose() and O/S buffering

2004-07-01 Thread Michael Sims
Andrew Hill wrote: > $fp = fopen("/tmp/lock.txt", "w+"); > if (flock($fp, LOCK_EX)) { // do an exclusive lock >fwrite($fp, "$processName\n"); >flock($fp, LOCK_UN); // release the lock > } else { >echo "Couldn't lock the file !"; > } > fclose($fp); [...] > In this case, although process

[PHP] flock(), fclose() and O/S buffering

2004-07-01 Thread Andrew Hill
Hi all, I have a question about the way flock() and fclose() work in PHP. Consider the following code, slightly modified from the flock() PHP manual page: $fp = fopen("/tmp/lock.txt", "w+"); if (flock($fp, LOCK_EX)) { // do an exclusive lock fwrite($fp, "$processName\n"); flock($fp, LOCK_U