【求助】perl中异常的fd无法释放
时间:2010-09-20
来源:互联网
本帖最后由 天野飘 于 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]
我想抓监控某块网卡上有没数据包,如果不用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]
作者: 天野飘 发布时间: 2010-09-20
自己顶个先。。。。
作者: 天野飘 发布时间: 2010-09-20
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28