1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! A simple crate to catch signals and set a boolean flag for later use.
//!
//! This crate doesn't create threads behind the scene.
//!
//! [](https://crates.io/crates/signalbool)
//! [](https://github.com/lilydjwg/rust-signalbool)
//!
//! # Example
//!
//! Here is a program that sleeps until it receives three `SIGINT` signals.
//!
//! ```
//! use nix::unistd::sleep;
//!
//! let mut sb = signalbool::SignalBool::new(
//! &[signalbool::Signal::SIGINT], signalbool::Flag::Interrupt,
//! ).unwrap();
//! let mut count = 0;
//!
//! loop {
//! sleep(10);
//! if sb.caught() {
//! println!("Caught SIGINT.");
//! count += 1;
//! sb.reset();
//! if count == 3 {
//! break;
//! }
//! }
//! }
//! ```
use crateunix as imp;
use cratewindows as imp;
pub use crateSignal;
/// A struct that catches specified signals and sets its internal flag to `true`.
///
/// Note: any previously-registered signal handlers will be lost.
;
;
/// flag controlling the restarting behavior.
///
/// Note that most functions in `std` ignore `EINTR` and continue their operations.
///
/// See manpage [`signal(7)`](http://man7.org/linux/man-pages/man7/signal.7.html) for details.