Function tokio::signal::windows::ctrl_logoff

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

Creates a new stream which receives “ctrl-logoff” notifications sent to the process.

Examples

use tokio::signal::windows::ctrl_logoff;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // An infinite stream of CTRL-LOGOFF events.
    let mut stream = ctrl_logoff()?;

    stream.recv().await;
    println!("got CTRL-LOGOFF. Cleaning up before exiting");

    Ok(())
}