pub fn ctrl_break() -> Result<CtrlBreak>
Available on Windows and crate feature
signal
only.Expand description
Creates a new listener which receives “ctrl-break” notifications sent to the process.
§Examples
use tokio::signal::windows::ctrl_break;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// A listener of CTRL-BREAK events.
let mut signal = ctrl_break()?;
// Print whenever a CTRL-BREAK event is received.
loop {
signal.recv().await;
println!("got signal CTRL-BREAK");
}
}