Created
December 17, 2013 21:30
-
-
Save ftdysa/8012924 to your computer and use it in GitHub Desktop.
sig alarm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eval { | |
local $SIG{ALRM} = sub { die "timed out" }; | |
alarm 5; # 5 seconds | |
# do something | |
alarm 0; # Clears alarm. | |
}; | |
alarm 0; | |
if( $@ and $@ =~ /timed out/) { | |
# there was an error # | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment