1 #![warn(rust_2018_idioms)] 2 #![cfg(feature = "full")] 3 #![cfg(unix)] 4 #![cfg(not(miri))] // No `sigaction` on Miri 5 6 mod support { 7 pub mod signal; 8 } 9 use support::signal::send_signal; 10 11 use tokio::signal; 12 use tokio::sync::oneshot; 13 use tokio_test::assert_ok; 14 15 #[tokio::test] ctrl_c()16async fn ctrl_c() { 17 let ctrl_c = signal::ctrl_c(); 18 19 let (fire, wait) = oneshot::channel(); 20 21 // NB: simulate a signal coming in by exercising our signal handler 22 // to avoid complications with sending SIGINT to the test process 23 tokio::spawn(async { 24 wait.await.expect("wait failed"); 25 send_signal(libc::SIGINT); 26 }); 27 28 let _ = fire.send(()); 29 30 assert_ok!(ctrl_c.await); 31 } 32