waiting on recurively forked children

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

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:

Has anyone ideas?

#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);

Kind regards,

Site Timeline