Which is why I said "or it is locked (maybe depending on the OS)" - it's an OS dependent behaviour. It's also why I went on to suggest you could use flock, although others have pointed out that that may not do quite what you want either.
True laziness is hard work
| [reply] |
If you think it through, it is entirely correct that Apache allows you to open this file.Think what would happen if Apache kept an exclusive lock on this file: nobody would ever be able to even read the file, unless they would have shutdown the webserver! Of course writing to the Apache log-file is not advised, but it can hardly be considered Apache's fault that you are trying to destroy its log. You might answer that reading a file is different from writing and the locking mechanism should account for that and a shared lock should just do that (the process holding the lock can read/write, all others can only read). Alas, locks are just advisory by nature, so you may ignore them at your own peril.
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
| [reply] |