in reply to RE: Re: Forking and waiting
in thread Forking and waiting

just wait for the CHILD in the parent:

my ($i, $return, $pid, @pids); for ($i = 1; $i <= 3; $i++) { if ($pid=fork) { push @pids, $pid; waitpid($pid,0); } elsif (defined $pid) { $return = &my_function($i); print "Returned: $return\n"; exit; } } print "All done.\n";

Replies are listed 'Best First'.
Re^4: Forking and waiting
by strictvars (Sexton) on Apr 15, 2005 at 19:20 UTC
    ++
    Thanks slayven for waitpid($pid,0);