With lock files I mean: Create a file to lock a resource and delete it when releasing it again.
Asked
Active
Viewed 154 times
0
-
1Can you show some example codes detailing your thoughts? – Pavan Manjunath Apr 20 '12 at 12:42
-
You might get some better quality answers if you provide some more information about the specific context you are working in. – Colin D Apr 20 '12 at 12:56
2 Answers
4
Directly from the man page:
NOTES
flock() does not lock files over NFS. Use fcntl(2) instead: that does work over NFS, given
a sufficiently recent version of Linux and a server which supports locking.
I'm not saying using lock files is the better option over NFS, though.

hroptatyr
- 4,702
- 1
- 35
- 38
-
`fcntl` locks or `lockf` should be used instead. `flock` is deprecated but plenty of broken software insists on still trying to use it... – R.. GitHub STOP HELPING ICE Apr 20 '12 at 13:10
1
some reasons not to use flock():
It does not work over NFS.
It is just an advisory lock, even if you use a lock there is no guarantee other processes will respect it.

Colin D
- 5,641
- 1
- 23
- 35