my $timeout = 20; # or whatever is appropriate eval { local $SIG{ALRM} = sub { die "timedout" }; alarm $timeout; # Your system call goes here.... alarm 0; }; if ($@) { # $@ will contain error message, if any }