getting notified on flock/lockf/fcntl changes without polling

629 views Asked by At

Is there a way (in Linux) of getting updates on the lockedness status of a file without polling?

I know that the status can be polled via a lockf(fd, F_TEST) or speculative LOCK_NB|LOCK_SH, but polling is bad(tm).

Of course, finding out when a file is NOT locked can be done with a simple lock attempt, but I want to sample the other edge too (use-case: a (large) program uses lockf to synchronize between instances - I can probably get it changed to flock, and I want to add a GUI that displays when the lock is acquirable, of course while not hogging the lock).

Note that inotify does not work in this case, at least on linux 3.9.1.

0

There are 0 answers