Created
February 13, 2017 12:26
-
-
Save kamaradclimber/144d5f12a09f6135e429e19089e50637 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/python | |
import time, datetime | |
import sys | |
from signal import * | |
signals = { | |
SIGABRT: 'SIGABRT', | |
SIGALRM: 'SIGALRM', | |
SIGBUS: 'SIGBUS', | |
SIGCHLD: 'SIGCHLD', | |
SIGCONT: 'SIGCONT', | |
SIGFPE: 'SIGFPE', | |
SIGHUP: 'SIGHUP', | |
SIGILL: 'SIGILL', | |
SIGINT: 'SIGINT', | |
SIGPIPE: 'SIGPIPE', | |
SIGPOLL: 'SIGPOLL', | |
SIGPROF: 'SIGPROF', | |
SIGQUIT: 'SIGQUIT', | |
SIGSEGV: 'SIGSEGV', | |
SIGSYS: 'SIGSYS', | |
SIGTERM: 'SIGTERM', | |
SIGTRAP: 'SIGTRAP', | |
SIGTSTP: 'SIGTSTP', | |
SIGTTIN: 'SIGTTIN', | |
SIGTTOU: 'SIGTTOU', | |
SIGURG: 'SIGURG', | |
SIGUSR1: 'SIGUSR1', | |
SIGUSR2: 'SIGUSR2', | |
SIGVTALRM: 'SIGVTALRM', | |
SIGXCPU: 'SIGXCPU', | |
SIGXFSZ: 'SIGXFSZ', | |
} | |
def handler(signum, frame): | |
sys.stdout.write('%s: Signal handler signal %s\n' % (datetime.datetime.now(), signum)) | |
sys.stdout.flush() | |
# Set the signal handler and a 5-second alarm | |
for num in signals: | |
signal(num, handler) | |
if __name__=="__main__": | |
while True: | |
sys.stdout.write("stdout running\n") | |
sys.stdout.flush() | |
time.sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment