tokio::signal::windows

Function ctrl_logoff

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

Creates a new listener 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>> {
    // A listener of CTRL-LOGOFF events.
    let mut signal = ctrl_logoff()?;

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

    Ok(())
}