my @children; for (my $i = 1;$i<=5;$i++){ my $pid = fork(); if ($pid){ push @children, $pid; } elsif ($pid == 0){ system("ssh $mch aplication"); exit; } else{ die "could not fork! \n"; } } foreach (@children){ waitpid($_,0); }