worktree-test/sighand.py

21 lines
427 B
Python
Raw Normal View History

2021-03-03 15:39:43 +00:00
import signal
import traceback
class SignalHandler:
def __init__(self):
# register signal handlers
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
def exit_gracefully(self, signum, frame):
print('captured signal %d' % signum)
traceback.print_stack(frame)
#print signal code
raise(SystemExit)