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