1 #![warn(rust_2018_idioms)]
2 #![cfg(feature = "full")]
3 #![cfg(unix)]
4 
5 mod support {
6     pub mod signal;
7 }
8 use support::signal::send_signal;
9 
10 use tokio::runtime::Runtime;
11 use tokio::signal::unix::{signal, SignalKind};
12 
13 #[test]
dropping_loops_does_not_cause_starvation()14 fn dropping_loops_does_not_cause_starvation() {
15     let kind = SignalKind::user_defined1();
16 
17     let first_rt = rt();
18     let mut first_signal =
19         first_rt.block_on(async { signal(kind).expect("failed to register first signal") });
20 
21     let second_rt = rt();
22     let mut second_signal =
23         second_rt.block_on(async { signal(kind).expect("failed to register second signal") });
24 
25     send_signal(libc::SIGUSR1);
26 
27     first_rt
28         .block_on(first_signal.recv())
29         .expect("failed to await first signal");
30 
31     drop(first_rt);
32     drop(first_signal);
33 
34     send_signal(libc::SIGUSR1);
35 
36     second_rt.block_on(second_signal.recv());
37 }
38 
rt() -> Runtime39 fn rt() -> Runtime {
40     tokio::runtime::Builder::new_current_thread()
41         .enable_all()
42         .build()
43         .unwrap()
44 }
45