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

Parricide? I suppose, but if you set up proper handling of SIGCHLD in your code and have a plan of what to do you should be OK.

# ---- yadayadayada # # Handler for SIGCHLD $SIG{CHLD}=sub { # do something here } ;

Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Replies are listed 'Best First'.
Re^4: Help with Fork bomb
by Anonymous Monk on Aug 30, 2012 at 20:47 UTC

    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; }
      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.