[][src]Module signal_hook::cleanup

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 SIGTERM, SIGINT or 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:

  • Registering the reset as part of the signal handlers. This is more reliable (even in case the application is already stuck in some kind of infinite loop, it would still work). This is done by register.
  • Manually resetting the handlers just before the shutdown. This is done with cleanup_signal.



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.