in reply to controlling child processes

Three - is there a better way to go about doing this?

Yes. You are duplicating the functonality of Parallel::ForkManager. All you need is the following:

use strict; use warnings; use Parallel::ForkManager (); use constant $MAX_PROCESSES => 3; { my $pm = Parallel::ForkManager->new($MAX_PROCESSES); foreach my $fw (qw(fw1 fw2 fw3 fw4 fw5)) { my $pid = $pm->start and next; exec "remotelogfile $fw logfile > /var/$fw.log" or die("Unable to launch \"remotelogfile $fw\": $!\n"); # Will never reach this, but that's ok since it only calls exit. $pm->finish; # Terminates the child process } }
or just
use Parallel::ForkManager (); my $pm = Parallel::ForkManager->new(3); foreach my $fw (qw(fw1 fw2 fw3 fw4 fw5)) { $pm->start and next; exec "remotelogfile $fw logfile > /var/$fw.log"; die("Unable to launch \"remotelogfile $fw\": $!\n"); }