|
|
|
|
|
by avar
3669 days ago
|
|
The flock() method is preferable when you don't need to use NFS because as you say it'll automatically clean the lock up if the process holding it dies. This gets rid of all the edge cases with stale locks in one fell swoop. But as you point out if you want to do this e.g. over NFS you should create a file, but then you need to deal with stale locks. If you can at all avoid that using flock() is generally better. |
|
And my instinct is that in a networked scenario, you're at least as worried about a machine dying as a process on the machine (i.e. a network partition). A flock()-based lock doesn't clean itself up if the client is unreachable, does it?