broker_tokio/signal/mod.rs
1//! Asynchronous signal handling for Tokio
2//!
3//! Note that signal handling is in general a very tricky topic and should be
4//! used with great care. This crate attempts to implement 'best practice' for
5//! signal handling, but it should be evaluated for your own applications' needs
6//! to see if it's suitable.
7//!
8//! The are some fundamental limitations of this crate documented on the OS
9//! specific structures, as well.
10//!
11//! # Examples
12//!
13//! Print on "ctrl-c" notification.
14//!
15//! ```rust,no_run
16//! use tokio::signal;
17//!
18//! #[tokio::main]
19//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
20//! signal::ctrl_c().await?;
21//! println!("ctrl-c received!");
22//! Ok(())
23//! }
24//! ```
25//!
26//! Wait for SIGHUP on Unix
27//!
28//! ```rust,no_run
29//! # #[cfg(unix)] {
30//! use tokio::signal::unix::{signal, SignalKind};
31//!
32//! #[tokio::main]
33//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
34//! // An infinite stream of hangup signals.
35//! let mut stream = signal(SignalKind::hangup())?;
36//!
37//! // Print whenever a HUP signal is received
38//! loop {
39//! stream.recv().await;
40//! println!("got signal HUP");
41//! }
42//! }
43//! # }
44//! ```
45
46mod ctrl_c;
47pub use ctrl_c::ctrl_c;
48
49mod registry;
50
51mod os {
52 #[cfg(unix)]
53 pub(crate) use super::unix::{OsExtraData, OsStorage};
54
55 #[cfg(windows)]
56 pub(crate) use super::windows::{OsExtraData, OsStorage};
57}
58
59pub mod unix;
60pub mod windows;