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?
Killing Zombies is the act of rendering the moving corpse completely motionless once again. It can be argued that the term killing is technically inaccurate, as despite the observed locomotion of the zombie, all other life functions have ceased. Still, the point is mostly one of semantics.
Weaknesses. Stupidity - Zombies have no intelligence and no survival instincts, and so they can be easily lured into traps. Speed - Traditionally, zombies cannot move very fast due to their decayed state and complete lack of coordination, making it relatively easy to outrun them or navigate through them.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With