#!/usr/bin/perl -w use strict; chomp (my $curdir = `pwd`); my $proc = '../delme.pl > proc.log 2>error.log'; my %kid; for (1 .. 4) { chdir $curdir; do { mkdir "test$_" or die $! } unless (-d "test$_"); chdir "test$_" or die $!; print "Launching: Process $_$/"; defined(my $cpid = fork) or warn $! and next; $kid{$cpid} = undef, next if %kid; exec $proc; exit 0; } delete $kid{wait()} while %kid; print "Done...$/";