#!/usr/bin/perl use strict; use warnings; my $delay = shift @ARGV || 1; # parameter my $timeout = 3; # seconds eval { ## Turn on timer. local $SIG{"__DIE__"}; local $SIG{CHLD}; local $SIG{ALRM} = sub { die "timed-out\n" }; alarm $timeout; my $verylongprocess = `sleep $delay`; alarm 0; # disable alarm }; die $@ if $@ eq "timed-out\n"; print "No timeout\n"; #### my $verylongprocess = `timeout $delay`;