parent { push @child_pids, $_[0] } #### # wait to reap all children for my $pid (@child_pids) { waitpid $pid, 0; }