- 论坛徽章:
- 0
|
本帖最后由 天野飘 于 2010-09-20 16:37 编辑
我想抓监控某块网卡上有没数据包,如果不用alarm,则可能在执行抓包时程序阻塞。但是这样引起一个问题,就是在没有流的情况下killall掉的tcpdump,可能有fd没关闭,这是个后台程序,fd可能会非常多?大家有没好点子啊?我没辙了。
顺便说下,用system执行tcpdump也不行。
sub tcpdump_receive_ip()
{
eval
{
alarm 1;
`nohup tcpdump -ni eth0 -c 10 greater 1358`;
alarm 0;
};
if ($@)
{
`killall tcpdump`;
return -1;
}
return 0;
}
才一会就这样:
linux:/home # l /proc/19784/fd
total 13
dr-x------ 2 root root 0 Sep 20 16:11 ./
dr-xr-xr-x 5 root root 0 Sep 20 16:11 ../
lr-x------ 1 root root 64 Sep 20 16:28 0 -> /dev/null
lrwx------ 1 root root 64 Sep 20 16:28 1 -> /dev/pts/9
lr-x------ 1 root root 64 Sep 20 16:35 10 -> pipe:[13794621]
lr-x------ 1 root root 64 Sep 20 16:35 11 -> pipe:[13798346]
lr-x------ 1 root root 64 Sep 20 16:35 12 -> pipe:[13798676]
lrwx------ 1 root root 64 Sep 20 16:11 2 -> /dev/pts/9
lr-x------ 1 root root 64 Sep 20 16:28 3 -> pipe:[13768065]
lr-x------ 1 root root 64 Sep 20 16:30 4 -> pipe:[13771924]
lr-x------ 1 root root 64 Sep 20 16:31 5 -> pipe:[13775769]
lr-x------ 1 root root 64 Sep 20 16:31 6 -> pipe:[13779550]
lr-x------ 1 root root 64 Sep 20 16:32 7 -> pipe:[13783394]
lr-x------ 1 root root 64 Sep 20 16:32 8 -> pipe:[13787296]
lr-x------ 1 root root 64 Sep 20 16:33 9 -> pipe:[13791022] |
|