11
I currently need to provide multiple keyboard interrupts for a program. Is there an easy way to do this with the signal class? I currently use the SIGINT/Ctrl+C but I can't find any other keyboard mappings.
Would be nice to have more than 2 signals. How can I either define more signals or is there a better way to capture an "interrupt from a user"?
Here is a highlevel view of the current code:
def shutdown(signal, frame):
if(signal==2): #sigint
print 'do something'
elif signal==XX:
print 'do something else'
# continued...
signal.signal(signal.SIGINT, shutdown)
signal.signal(signal.SOMEOTHERTYPE, shutdown)
print 'start'
t = Thread(target=run)
t.setDaemon(True)
t.start()
print 'Done, press ctrl c, or ctrl ? '
signal.pause()