github.com/vorner/signal-hook ↗
Rust library allowing to register multiple handlers for the same signal
Open this visualization on its own page →
Contributors
10
Lines of Code
490
From
2018-06-13
To
2020-12-26
About vorner/signal-hook
Signal-hook is a Rust library that provides safe and correct Unix signal handling by maintaining a global registry where applications can register multiple handlers for the same signal. Unix signals are notoriously difficult to handle correctly because they are a global resource shared across all libraries in a process, can interrupt execution from any thread at unpredictable times, and are constrained by POSIX restrictions on which functions are safe to call within a signal handler context.
The library solves these problems by allowing developers to register and later remove individual signal actions without disturbing handlers from other libraries or losing the ability to chain with previously installed handlers. It abstracts away the complexity of async-signal-safety by providing a global action registry that isolates signal handling logic from the unsafe constraints of raw signal handlers, making common signal handling patterns accessible from safe Rust code.
The library is dual-licensed under Apache 2.0 and MIT licenses, comes with comprehensive documentation, and includes support for common use cases through built-in helper actions beyond basic arbitrary action registration.