All pastes #31530 Raw Edit

Untitled

public text v1 · immutable
#31530 ·published 2005-11-28 14:55 UTC
rendered paste body
for($forkcount = 0; $forkcount < $maxfork; $forkcount++) {
 sleep 1;                      # so we don't overload ourselves
   if (my $pid = fork) {       # parent process, do nothing
   } elsif(defined $pid) {     # child process, do stuff
     print "> doing thing\n";
     sub_to_do();
     print "new child: number $forkcount\n";
     exit 0;
  } else {
     print STDERR "!! hit process limit\n";
}
while (1) { sleep 1; }