Function tokio::signal::windows::ctrl_shutdown
source · pub fn ctrl_shutdown() -> Result<CtrlShutdown>
Available on Windows and crate feature
signal
only.Expand description
Creates a new stream which receives “ctrl-shutdown” notifications sent to the process.
Examples
use tokio::signal::windows::ctrl_shutdown;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// An infinite stream of CTRL-SHUTDOWN events.
let mut stream = ctrl_shutdown()?;
stream.recv().await;
println!("got CTRL-SHUTDOWN. Cleaning up before exiting");
Ok(())
}