$ signal-hook
v0.4.4Unix signal handling
Latest Update Summary
Crate
Name: signal-hook New version: 0.4.0 Release date: 2025-12-26T11:57:36.503727Z
Crate readme
Short description Library for safe and correct Unix signal handling in Rust.
Long description Unix signals are inherently hard to handle correctly due to their global nature and the limitations set by the POSIX standard on handling functions. This library provides a global registry of actions for signal arrival, allowing multiple actions for the same signal while enabling the removal of actions. Helper actions are also provided for common use cases in safe Rust.
Features • Safe Rust implementation • Global registry of signal actions • Register multiple actions for the same signal • Chaining of previous signal handlers
Code Examples Basic usage
use std::io::Error;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
fn main() -> Result<(), Error> {
let term = Arc::new(AtomicBool::new(false));
signal_hook::flag::register(signal_hook::consts::SIGTERM, Arc::clone(&term))?;
while !term.load(Ordering::Relaxed) {
// Do some time-limited stuff here
}
Ok(())
}
Links • https://docs.rs/signal-hook
Release info
Release version: N/A
Release description N/A
Code Examples N/A
Patch update: 0.4.3 → 0.4.4
$ DOWNLOADS TREND
$ VERSION HISTORY
$ LINKS
$ INSTALL
cargo add signal-hookOr add to Cargo.toml: signal-hook = "0.4.4"