来自man lsof
:
FD 是文件的文件描述符编号或: FD 后跟以下字符之一,描述文件打开的模式:
The mode character is followed by one of these lock characters, describing the type of lock applied to the file:
R for a read lock on the entire file;
W for a write lock on the entire file;
space if there is no lock.
Run Code Online (Sandbox Code Playgroud)因此,R
在3uR
平均读取/共享锁由发出613
PID。
#lsof /tmp/file
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
perl 613 turkish 3uR REG 8,2 0 1306357 /tmp/file
Run Code Online (Sandbox Code Playgroud)
直接从 读取/proc/locks
比lsof
,
perl -F'[:\s]+' -wlanE'
BEGIN { $inode = (stat(pop))[1]; @ARGV = "/proc/locks" }
say "pid:$F[4] [$_]" if $F[7] == $inode
' /tmp/file
Run Code Online (Sandbox Code Playgroud)