$ cat /proc/locks 1: POSIX ADVISORY WRITE 458 03:07:133880 0 EOF 2: FLOCK ADVISORY WRITE 404 03:07:133879 0 EOF
The fields are: ordinal number(1), type(2), mode(3), type(4), pid(5), maj:min:inode(6) start(7) end(8).
Question: how to find the corresponding file is being locked?
Best Answer
To get all of them:
Sometimes, the process whose
pid
is referenced in/proc/lock
will have died. You can change the"/proc/$p/fd"
above to/proc/*/fd
to look for them among all processes fds.(note that it is an approximation as we're only checking the inode number, not the device number, but chances that we pick the wrong file (same inum on a different fs) are very slim).