novax_tokio/lib.rs
1use tokio::sync::oneshot;
2use tokio::task::JoinHandle;
3
4pub fn ctrl_c_handler() -> Result::<(JoinHandle::<bool>, oneshot::Receiver::<bool>), std::io::Error> {
5 let (tx, rx) = oneshot::channel::<bool>();
6 Ok (
7 (
8 tokio::task::spawn_blocking(
9 move || {
10 let _ = tokio::spawn(async move{
11 tokio::signal::ctrl_c().await?;
12 let _ = tx.send(true);
13 Ok::<(), std::io::Error>(())
14 });
15 true
16 }
17 ),
18 rx
19 )
20 )
21}
22
23// re-export
24pub use tokio;