#!/usr/bin/perl -w # Prints the PID of a process that is holding a lock on the file # $ARGV[0]. Surely there's a better way to get locker info? # Something like /proc/timer_list is for sleeps/timeouts? use Fcntl; $lock_format = "s2l5"; # For the Linux 64-bit interface sysopen(FD, $ARGV[0], O_RDONLY) or die "open $!"; $fs = pack($lock_format, F_RDLCK, 0, 0, 0, 1, 1, 0); fcntl(FD, F_GETLK, $fs) or die "fcntl $!"; print((unpack $lock_format, $fs)[6] . "\n");