#!/usr/bin/perl my $pid = open my $fh, "your_command ... |" or die $!; eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm 600; # ... optionally read any output from the subprocess # while (<$fh>) { ... } close $fh; # waits for child alarm 0; }; if ($@ eq "alarm\n") { # timed out kill 9, $pid; }