my @childs; for ( my $count = 1; $count <= 4; $count++) { my $pid = fork(); if ($pid) { push(@childs, $pid); }elsif($pid == 0){ testExec($count); exit 0; }else{ die "couldnt fork: $!\n"; } } foreach (@childs) { my $tmp = waitpid($_, 0); print "done with pid $tmp\n"; } ######################## sub testExec($){ my $arg = shift; system("execB $arg"); }