if ($pid[$i]=fork()) { # parent process waitpid($pid[$i], 0); # wait for child close ($wh); ... #### ## ## launch children ## for( $i = 0 ; $i < NUMPROCS ; $i++ ) { $pid[$i] = fork() ; next if( $pid[$i] != 0 ) ; # fork next process ## ## child stuff ## exit(0) ; # when finished } ## ## gather children ## foreach( @pid ) { waitpid($_, 0) ; # waits for each child if( $? != SOMETHINGGOOD ) { # bad exit status } }