in reply to Re^3: Help with Fork bomb
in thread Help with Fork bomb

I'm using Blue_cowdawg's code. It does this:

$SIG{CHLD}=\&catchChildDeath; # Deal with the death of a child. A sad event to be sure. sub catchChildDeath{ printf "Death of child noted.\n"; $children--; $children = ( $children < 0 ? 0 : $children); unless ($spawnEnabled){ $spawnEnabled = ( $children < $min_child ? 1 : 0 ); } printf "There are %d children running\n",$children; }

My sub that the child runs exits at its end:

sub my_child_work{ my $x = shift; print "child x $x "; sleep 1; exit; }

Replies are listed 'Best First'.
Re^5: Help with Fork bomb
by ww (Archbishop) on Aug 30, 2012 at 22:47 UTC
    Slightly off topic (but rather important in some circumstances)...

    Perl is not C ...
        and   printf   is not Perl's   print   (nor is it say).

    So perhaps you should reconsider using it before it gets to be a habit that gets you in trouble.