in reply to Re: Forking and waiting
in thread Forking and waiting
I just tried this variation with some success:
my ($i, $return, $pid, @pids);
for ($i = 1; $i <= 3; $i++) {
if ($pid=fork) {
push @pids, $pid;
} elsif (defined $pid) {
$return = &my_function($i);
print "Returned: $return\n";
exit;
}
}
foreach my $childpid (@pids) {
waitpid($childpid, 0);
}
print "All is done!\n";
Does that seem a reasonable/efficient way to handle this?Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Re: Forking and waiting
by slayven (Pilgrim) on May 29, 2000 at 19:16 UTC | |
by strictvars (Sexton) on Apr 15, 2005 at 19:20 UTC | |
|
RE: RE: Re: Forking and waiting
by takshaka (Friar) on May 29, 2000 at 22:44 UTC | |
by slayven (Pilgrim) on May 29, 2000 at 23:27 UTC | |
by Silas (Novice) on May 30, 2000 at 21:53 UTC | |
by takshaka (Friar) on May 30, 2000 at 23:27 UTC |