wait will sit and sleep until SIGCHLD triggers from any source. If you want to wait for a specific child, use waitpid.
My pet idiom for waiting for multiple kids is this:
If the kids need arguments, or you need to check their exit status, you'll need to modify the control structures. The family_bible hash makes the wait strategy insensitive to ordering (as it must be) and provides a convenient control structure for knowing when you're done.my %family_bible = (); # @todo is an array of coderefs sub () {...;return $status} for (@todo) { my $kid; defined $kid = fork or last; $kid or exit &$_; $family_bible{$kid}++; } delete $family_bible{-wait} while %family_bible;
There are, of course, CPAN modules to handle all this for you. Parallel::ForkManager is one I recommend.
After Compline,
Zaxo
In reply to Re: help using the wait() command
by Zaxo
in thread help using the wait() command
by Ras
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |