mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
A step towards collapsing Tokio sub crates into a single `tokio` crate (#1318). The `net` implementation is now provided by the main `tokio` crate. Functionality can be opted out of by using the various net related feature flags.
29 lines
651 B
Rust
29 lines
651 B
Rust
#![cfg(unix)]
|
|
#![warn(rust_2018_idioms)]
|
|
|
|
mod support {
|
|
pub mod signal;
|
|
}
|
|
use support::signal::send_signal;
|
|
|
|
use tokio::prelude::*;
|
|
use tokio::signal;
|
|
use tokio::sync::oneshot;
|
|
|
|
#[tokio::test]
|
|
async fn ctrl_c() {
|
|
let ctrl_c = signal::ctrl_c().expect("failed to init ctrl_c");
|
|
|
|
let (fire, wait) = oneshot::channel();
|
|
|
|
// NB: simulate a signal coming in by exercising our signal handler
|
|
// to avoid complications with sending SIGINT to the test process
|
|
tokio::spawn(async {
|
|
wait.await.expect("wait failed");
|
|
send_signal(libc::SIGINT);
|
|
});
|
|
|
|
let _ = fire.send(());
|
|
let _ = ctrl_c.into_future().await;
|
|
}
|