Clownburner has asked for the wisdom of the Perl Monks concerning the following question:
Also, I would like to know if there is a way to prevent this from becoming a fork() bomb if the @targets array contains a LOT of targets (it could easily contain 500+ targets), so how do I limit the number of children while still covering all the @targets?my $prox = scalar(@targets) -1; my ($i, $ret, $pid, @pids); for ($i = 0; $i <= $prox; $i++) { if ($pid=fork) { push @pids, $pid; waitpid($pid,0); } elsif (defined $pid) { my $next = @targets[${i}]; $ret = &check_status($next); if ($ret) { $avail ++; } exit; } } my $success = ( $avail / scalar(@targets) ) * 100; $success = sprintf('%.2f',$uptime); print "$success% successful\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tallying results from Forking processes...
by chipmunk (Parson) on Mar 21, 2001 at 09:37 UTC | |
|
Re: Tallying results from Forking processes...
by merlyn (Sage) on Mar 21, 2001 at 07:49 UTC | |
by kschwab (Vicar) on Mar 21, 2001 at 08:43 UTC | |
|
Success!
by Clownburner (Monk) on Mar 22, 2001 at 05:03 UTC | |
|
Minor Correction:
by Clownburner (Monk) on Mar 21, 2001 at 07:24 UTC |