Function tokio::signal::windows::ctrl_break

source ·
pub fn ctrl_break() -> Result<CtrlBreak>
Available on Windows and crate feature signal only.
Expand description

Creates a new stream 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>> {
    // An infinite stream of CTRL-BREAK events.
    let mut stream = ctrl_break()?;

    // Print whenever a CTRL-BREAK event is received.
    loop {
        stream.recv().await;
        println!("got signal CTRL-BREAK");
    }
}