How can I find out if someone else has a file open?

How can I find out if someone else has a file open?


This is another candidate for `Frequently Unanswered Questions' because,
in general, your program should never be interested in whether someone
else has the file open. If you need to deal with concurrent access to
the file, then you should be looking at advisory locking.



This is, in general, too hard to do anyway. Tools like fuser and
lsof that find out about open files do so by grovelling through
kernel data structures in a most unhealthy fashion. You can't usefully
invoke them from a program, either, because by the time you've found out
that the file is/isn't open, the information may already be out of date.






Home FAQ