my $timeout = 5; eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm $timeout; my $ret = qx/ping db01/; alarm 0; }; if ($@) { # timed out print "timeout handling ($! - $@) ...\n"; die unless $@ eq "alarm\n"; # propagate unexpected errors } else { # didn't print "no timeout timeout handling...\n"; }
I am writing watchdog scripts an I need response from the clients whithin a defined timeout period.
Any suggestions?
TIA
Retitled by g0n from 'timout problem with alarm'.
In reply to timeout problem with alarm by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |