async-signal-with-info
Asynchronous signal handling.
This crate provides the Signals type, which can be used to listen for POSIX signals asynchronously. It can be seen as an asynchronous version of signal_hook::iterator::Signals.
This is a fork of async-signal to also provide siginfo_t via the async stream. As siginfo_t is a Unix specific feature, support for Windows is also removed from the crate.
Implementation
This crate uses the signal_hook_registry crate to register a listener for each signal. That listener will then send a message through a Unix socket to the Signals type, which will receive it and notify the user. Asynchronous notification is done through the futures-channel crate.
A background thread is used for reading signal messages to avoid signal losses caused by buffer overruns, which is a problem for the original crate.
Examples
use ;
use *;
use low_level;
// Register the signals we want to receive.
let mut signals = new?;
// Wait for a signal to be received.
while let Some = signals.next.await
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.