#!/usr/bin/perl use strict; use Time::HiRes qw(usleep); my $max = 0; while(my $prog = ) { print STDERR "$prog"; $max++; die "Unable to fork\n" unless(defined(my $pid = fork)); if($pid == 0) # child { die "Unable to exec\n" unless(exec("/usr/bin/ssh localhost /bin/sleep 10")); # die "Unable to exec\n" unless(exec("/bin/sleep 10")); exit(0); } usleep(100000); } for(my $i = 0; $i < $max; $i++) { wait; } print STDERR "\nDONE\n";