$ lsof /usr/lib/firefox-3.6.10/firefox-bin
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
firefox-b 2282 beyes txt REG 8,2 50636 10488017 /usr/lib/firefox-3.6.10/firefox-bin
#include <sys/stat.h>
#include <fcntl.h>
int main()
{
int fd, fd1, fd2;
fd = open ("main.c", O_RDONLY);
fd1 = open ("pipe.c", O_RDONLY);
sleep (60);
close (fd);
close (fd1);
return (0);
}
$ lsof lsof.exe
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
lsof.exe 2995 beyes txt REG 8,5 8384 11406523 lsof.exe
beyes@beyes-desktop:~/books/ldd3-samples/scull$ lsof -c lsof.exe
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
lsof.exe 2995 beyes cwd DIR 8,5 4096 11403436 /home/beyes/books/ldd3-samples/scull
lsof.exe 2995 beyes rtd DIR 8,2 4096 2 /
lsof.exe 2995 beyes txt REG 8,5 8384 11406523 /home/beyes/books/ldd3-samples/scull/lsof.exe
lsof.exe 2995 beyes mem REG 8,2 1405508 5505227 /lib/tls/i686/cmov/libc-2.11.1.so
lsof.exe 2995 beyes mem REG 8,2 113964 5505427 /lib/ld-2.11.1.so
lsof.exe 2995 beyes 0u CHR 136,2 0t0 5 /dev/pts/2
lsof.exe 2995 beyes 1u CHR 136,2 0t0 5 /dev/pts/2
lsof.exe 2995 beyes 2u CHR 136,2 0t0 5 /dev/pts/2
lsof.exe 2995 beyes 3r REG 8,5 16424 11403438 /home/beyes/books/ldd3-samples/scull/main.c
lsof.exe 2995 beyes 4r REG 8,5 11138 11403440/home/beyes/books/ldd3-samples/scull/pipe.c
lsof -p pid
lsof -i [46] [protocol] [@hostname] [:service | port]
$ lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
firefox-b 2282 beyes 27u IPv4 32426 0t0 TCP beyes-desktop.local:48096->58.51.95.10:www (ESTABLISHED)
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |