Last active
January 4, 2017 05:01
-
-
Save jbbarth/b63b21b98dd6ac32e2820a7c948c2f0e to your computer and use it in GitHub Desktop.
time.sleep() immediately returns when a signal is received
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
import time | |
import signal | |
def abrt_handler(signum, frame): | |
print "Hey I catched a signal {}".format(signum) | |
signal.signal(signal.SIGABRT, abrt_handler) | |
while True: | |
time.sleep(5) | |
print "... stil sleeping" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To test it once:
And for the more violent version:
(and
Ctrl+C
to stop, since SIGINT is not catched)