[−][src]Module signal_hook::iterator
An iterator over incoming signals.
This provides a higher abstraction over the signals, providing
the SignalsInfo
structure which is able to iterate over the
incoming signals. The structure is parametrized by an
Exfiltrator
, which specifies what information is returned
for each delivered signal.
The Signals
is a type alias for the common case when it is enough to get the signal number.
Examples
extern crate libc; extern crate signal_hook; use std::io::Error; use signal_hook::iterator::Signals; fn main() -> Result<(), Error> { let mut signals = Signals::new(&[ signal_hook::SIGHUP, signal_hook::SIGTERM, signal_hook::SIGINT, signal_hook::SIGQUIT, ])?; 'outer: loop { // Pick up signals that arrived since last time for signal in signals.pending() { match signal as libc::c_int { signal_hook::SIGHUP => { // Reload configuration // Reopen the log file } signal_hook::SIGTERM | signal_hook::SIGINT | signal_hook::SIGQUIT => { break 'outer; }, _ => unreachable!(), } } // Do some bit of work ‒ something with upper limit on waiting, so we don't block // forever with a SIGTERM already waiting. } println!("Terminating. Bye bye"); Ok(()) }
Re-exports
pub use self::backend::Handle; |
pub use self::backend::Pending; |
Modules
backend | A backend module for implementing the iterator like
|
exfiltrator | An abstraction over exfiltrating information out of signal handlers. |
Structs
Forever | An infinit iterator of arriving signals. |
SignalsInfo | The main structure of the module, representing interest in some signals. |
Type Definitions
Signals | A type alias for an iterator returning just the signal numbers. |