in reply to heartbeat script. Hung-server proof.

The classical thing to do is set a handler for SIGALRM which throws an exception (sub {die "Timeout"}), set the alarm for X seconds, and then in an eval do whatever thing you want to be able to timeout on. Last statement of the eval typically is 'alarm(0)'.

Check whether the eval succeeded. If not, check $@. If it matches "Timeout", you timed out. Otherwise, some other exception was thrown.

perldoc -f alarm will shown an example.

  • Comment on Re: heartbeat script. Hung-server proof.

Replies are listed 'Best First'.
Re^2: heartbeat script. Hung-server proof.
by ecarceller (Initiate) on Nov 06, 2008 at 18:20 UTC
    Right on the money. Thanks a lot!!!!!!