B
bernd.web
Hi all,
I am trying to wait like the bash '"wait" on all my forked processes.
A recursive routine that forked off children is called from main.
Using `ps` polling I managed to accomplish this, but how to use "wait"
to wait for (great)grandchildren in the original parent without
waiting during the recursion?
I would not like to wait for completion of children in the recursion
but only in the main.
However, I have not been able to figure out how to do this.
I did have a look at:
http://perldoc.perl.org/perlipc.html#Signals
http://perldoc.perl.org/perlfaq8.html
Has anyone ideas?
do_fork(1);
#continue when all children, and the children of the children etc...
are finished
print "All sub processes completed\n";
sub do_fork {
#fork off children
my $depth = shift;
if ($depth < 10) {
for(my $i = 0; $i < 4; $i++) {
unless ( fork ) {
#do something......
do_fork($depth + 1);
exit;
}
}
Kind regards,
Bernd
I am trying to wait like the bash '"wait" on all my forked processes.
A recursive routine that forked off children is called from main.
Using `ps` polling I managed to accomplish this, but how to use "wait"
to wait for (great)grandchildren in the original parent without
waiting during the recursion?
I would not like to wait for completion of children in the recursion
but only in the main.
However, I have not been able to figure out how to do this.
I did have a look at:
http://perldoc.perl.org/perlipc.html#Signals
http://perldoc.perl.org/perlfaq8.html
Has anyone ideas?
do_fork(1);
#continue when all children, and the children of the children etc...
are finished
print "All sub processes completed\n";
sub do_fork {
#fork off children
my $depth = shift;
if ($depth < 10) {
for(my $i = 0; $i < 4; $i++) {
unless ( fork ) {
#do something......
do_fork($depth + 1);
exit;
}
}
Kind regards,
Bernd