1

How can i know if someone is writing to a file , so i can skip writing or reading it ? file-locking could be used here , but there are some problems found ! like this one : https://bugs.php.net/bug.php?id=54453

Any other ideas ?

I want to skip writing/reading to a file without waiting for the file to be unlocked like the case in LOCK_EX or LOCK_SH , where code hangs till file is unlocked !

Rami Dabain
  • 4,709
  • 12
  • 62
  • 106
  • If you control access to the file, then don't use the buggy locks and you'll be fine. – Marc B Oct 18 '11 at 14:31
  • [this](http://stackoverflow.com/questions/3149324/php-check-if-file-locked-with-flock) may be useful –  Oct 18 '11 at 14:34
  • @ user973254 not working @Marc , couldn't understand you – Rami Dabain Oct 18 '11 at 14:49
  • @ronan: if your code is the only code/app that touches that file, then you'll KNOW what kind of locks are in use and don't have to worry about lock_nb being buggy. – Marc B Oct 18 '11 at 14:51
  • @MarcB yes my code is the only one that plays with those files , the question is how to know it is locked without the buggy flock and its friends ? – Rami Dabain Oct 18 '11 at 14:56
  • There's always the old standby of a flag file you create while fiddling with the file, and then remove afterwards. – Marc B Oct 18 '11 at 14:58

0 Answers0