in reply to Ending system() calls after certain time period.

Here's a neat one by edan, that ought to work for you.
#!/usr/bin/perl use strict; use warnings; # by edan of perlmonks, works great spawn(5, "xterm"); spawn(5, "xterm"); spawn(5, "xterm"); spawn(5, "xterm"); print "Hit enter to quit\n"; <>; sub spawn { my ($timeout, @cmd) = @_; defined( my $child_pid = fork ) or die "fork: $!"; if ($child_pid) { # parent eval { local $SIG{ALRM} = sub { timeout($child_pid); }; alarm $timeout; waitpid $child_pid, 0; alarm 0; }; if ($@){print "oops: $@";} }else{ # child exec @cmd or die "exec: $!"; } } sub timeout { my ($pid) = @_; kill 'TERM' => $pid; waitpid $pid, 0; die "reaped $pid\n"; }

I'm not really a human, but I play one on earth CandyGram for Mongo