lsof (my preference) or
lslk (specifically for file locks):
[root@policyServer ~]# lslk | grep "master.lock"
SRC PID DEV INUM SZ TY M ST WH END LEN NAME
master 1650 253,0 12423 33 w 0 0 0 0 0 /var/lib/postfix/master.lock
[root@policyServer ~]# lsof | grep "master.lock"
master 1650 root 10uW REG 253,0 33 12423 /var/lib/postfix/master.lock
Output of lslk is self-expanatory but
lsof puts the lock description in the "FD" column (which is
10uW above). From the man page:
The mode character is followed by one of these lock characters, describing the type of lock applied to the file:
N for a Solaris NFS lock of unknown type;
r for read lock on part of the file;
R for a read lock on the entire file;
w for a write lock on part of the file;
W for a write lock on the entire file;
u for a read and write lock of any length;
U for a lock of unknown type;
x for an SCO OpenServer Xenix lock on part of the file;
X for an SCO OpenServer Xenix lock on the entire file;
space if there is no lock.
So the "FD" column of
lsof above breaks down to:
10 The literal descriptor of this open file. What's linked to by
u File is open for reading and writing
W program has a write lock on the file.