小智 5
该命令sudo lsof -n |grep "st=07"
似乎有效。
为了测试它,我ping
在一个终端上运行如下图以生成 ICMP 数据包
arul@cheetah:~$ ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.048 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.049 ms
Run Code Online (Sandbox Code Playgroud)
在另一个终端上,我运行lsof
如下。您可以看到输出显示了进程和作为 ICMP 数据包来源的 pid。
arul@cheetah:~$ sudo lsof -n |grep "st=07"
ping 3344 arul 3u raw 0t0 602086 00000000:0001->00000000:0000 st=07
Run Code Online (Sandbox Code Playgroud)
来源:https : //stackoverflow.com/questions/23327689/identify-the-pid-of-process-which-is-transmitting-icmp-packets