Function tokio::signal::windows::ctrl_c [−][src]
pub fn ctrl_c() -> Result<CtrlC>
This is supported on crate feature
signal
only.Expand description
Creates a new stream which receives “ctrl-c” notifications sent to the process.
Examples
use tokio::signal::windows::ctrl_c; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { // An infinite stream of CTRL-C events. let mut stream = ctrl_c()?; // Print whenever a CTRL-C event is received. for countdown in (0..3).rev() { stream.recv().await; println!("got CTRL-C. {} more to exit", countdown); } Ok(()) }