If you do not want to override your own handler, make sure you install it:
if signal.getsignal(signal.SIGINT) in [signal.SIG_IGN, signal.SIG_DFL]: signal.signal(signal.SIGINT, hi)
According to the documentation , it is possible that some excellent process has already reassigned a default handler. If you do not want to override this, add None to the signal list.
The obvious wrapper for signal.signal(..., signal.SIG_IGN) is the not in test.
added in response to comment
Linking signal handlers are not often executed because the signals are so granular. If I really wanted to do this, I would run the atexit model and register the functions that will be called by your handler.
source share