僵尸如何造成伤害?
来自 perlipc/Signals:
eval {
local $SIG{ALRM} = sub { die "alarm clock restart" };
alarm 10;
flock(FH, 2); # blocking write lock
alarm 0;
};
if ($@ and $@ !~ /alarm clock restart/) { die }
如果超时的操作是system()或qx(),这种技术很容易产生僵尸。如果这对您很重要,您需要执行自己的 fork() 和 exec(),并终止错误的子进程。
我有一个类似的代码,其中超时的操作是 system() 或 qx()。
僵尸的坏处是它们会消耗内存,还是僵尸有更多的伤害方式?
From perlipc/Signals:
eval {
local $SIG{ALRM} = sub { die "alarm clock restart" };
alarm 10;
flock(FH, 2); # blocking write lock
alarm 0;
};
if ($@ and $@ !~ /alarm clock restart/) { die }
If the operation being timed out is system() or qx(), this technique is liable to generate zombies. If this matters to you, you'll need to do your own fork() and exec(), and kill the errant child process.
I have a similar code, where the operation being timed out is system() or qx().
Is the bad thing about zombies that they consume memory or are there more ways zombies can harm?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
主要问题是它们消耗进程表槽。 Linux 的进程表可以容纳 64k 条目,因此这不太可能导致问题,除非您进行大量分叉而不清理僵尸进程。我预计大多数(如果不是全部)其他现代 *nix 都有相同大小的进程表。不过,当你运行
ps
时,它看起来确实很难看。内存并不是真正的问题,因为每个僵尸只占用几个字节来记录其退出状态。
The primary issue is that they consume process table slots. Linux's process table can hold 64k entries, so this isn't likely to result in problems unless you do a lot of forking without cleaning up the zombies. I expect that most, if not all, other modern *nixes have process tables of the same size. It does look ugly when you run
ps
, though.Memory isn't really a problem, as each zombie only takes up a few bytes to record its exit status.
它们消耗进程表中的内存和空间。
They consume memory and space in the process table.