Cleaning up signals.
The routines in this module allow resetting the signals of an application back to defaults. This is intended for the following situation:
- A terminal signal (eg. a
SIGINTor something similar) is received.
- The application resets the signal handlers to defaults.
- The application proceeds to perform some kind of shutdown (saving data, cleaning up, ...).
- If another such signal is received, the application is terminated right away the hard way, without finishing the shutdown.
The alternative of leaving the original signals in place might be problematic in case the shutdown takes a long time or when it gets stuck. In such case the application would appear to ignore the signal and just refuse to die.
There are two ways to perform the reset:
Resets the signal handler to the default one.
Resets the signal handler to the default one and removes all its hooks.
Register a cleanup after receiving a signal.