当我想查看使用 的进程的打开文件列表时ls -l /proc/pid/fd
,我看到了一些套接字描述符。如何找到相应的文件名?
lr-x------ 1 u1 users 64 Sep 15 14:45 0 -> /dev/null
lrwx------ 1 u1 users 64 Sep 15 14:45 1 -> /dev/pts/3
lrwx------ 1 u1 users 64 Sep 15 14:45 10 -> socket:[507942]
l-wx------ 1 u1 users 64 Sep 15 14:45 2 -> pipe:[505993]
l-wx------ 1 u1 users 64 Sep 15 14:45 22 -> pipe:[505994]
l-wx------ 1 u1 users 64 Sep 15 14:45 3 -> /dev/null
lrwx------ 1 u1 users 64 Sep 15 14:45 4 -> socket:[507938]
lrwx------ 1 u1 users 64 Sep 15 14:45 5 -> socket:[507939]
lrwx------ 1 u1 users 64 Sep 15 14:45 6 -> socket:[486323]
lrwx------ 1 u1 users 64 Sep 15 14:45 7 -> socket:[486324]
lrwx------ 1 u1 users 64 Sep 15 14:45 8 -> socket:[509999]
lrwx------ 1 u1 users 64 Sep 15 14:45 9 -> socket:[507941]
我lsof -p pid
也看到了套接字。
atIcoFoam 24376 u1 0r CHR 1,3 0t0 1029 /dev/null
atIcoFoam 24376 u1 1u CHR 136,3 0t0 6 /dev/pts/3
atIcoFoam 24376 u1 2w FIFO 0,8 0t0 506122 pipe
atIcoFoam 24376 u1 3w CHR 1,3 0t0 1029 /dev/null
atIcoFoam 24376 u1 4u unix 0x0000000000000000 0t0 511127 socket
atIcoFoam 24376 u1 5u unix 0x0000000000000000 0t0 511128 socket
atIcoFoam 24376 u1 6u IPv4 510153 0t0 TCP *:37340 (LISTEN)
atIcoFoam 24376 u1 7u IPv6 510154 0t0 TCP *:43305 (LISTEN)
atIcoFoam 24376 u1 8u IPv4 512654 0t0 TCP hpclab.ws05:57696->hpclab.ws05:33141 (ESTABLISHED)
atIcoFoam 24376 u1 9u IPv4 508030 0t0 TCP *:1027 (LISTEN)
atIcoFoam 24376 u1 10u IPv6 508031 0t0 TCP *:1027 (LISTEN)