in reply to A flock()alypse now
Semaphore files have their uses:
Also, if you are going to just lock the file you want to modify instead of using a semaphore file, why are you opening the file, flock()ing the filehandle, then opening the file again?
Open the file with the permissions you'll need to perform the operations you've got planned, flock() it, do the operation, close the file.
Advisory locking never "plays well with others" if one of the those "others" ignores a lock, be it on a semaphore file, or the file itself.
Generally, advisory locks are good enough.
I'd be surprised if there isn't a way of controlling other processes, and making sure that they go through filehandling/locking properly.
Update: Correction. Removed discussion on bad example (since author _knows_ it's bad :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A flock()alypse now
by ferrency (Deacon) on Jul 02, 2002 at 18:42 UTC |