#! perl -slw use strict; use threads; use threads::shared; my( $max, $run_count ) = 5; LOOP1:while( $run_count < $max ) { my $end = time() + 10 * 60; my $pid :shared; async { $pid = open SHELL, qq[| ./sh1.sh] or die $!; }->detach; sleep 1 until $pid; sleep 1 while kill 0, $pid and time() < $end; kill 9, $pid; $run_count++; }