-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
signal: add
SignalKind::info
on illumos (#6995)
- Loading branch information
1 parent
c032ea0
commit 480c010
Showing
2 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#![warn(rust_2018_idioms)] | ||
#![cfg(feature = "full")] | ||
#![cfg(any( | ||
target_os = "dragonfly", | ||
target_os = "freebsd", | ||
target_os = "macos", | ||
target_os = "netbsd", | ||
target_os = "openbsd", | ||
target_os = "illumos" | ||
))] | ||
#![cfg(not(miri))] // No `sigaction` on Miri | ||
|
||
mod support { | ||
pub mod signal; | ||
} | ||
use support::signal::send_signal; | ||
|
||
use tokio::signal; | ||
use tokio::signal::unix::SignalKind; | ||
use tokio::sync::oneshot; | ||
use tokio::time::{timeout, Duration}; | ||
|
||
#[tokio::test] | ||
async fn siginfo() { | ||
let mut sig = signal::unix::signal(SignalKind::info()).expect("installed signal handler"); | ||
|
||
let (fire, wait) = oneshot::channel(); | ||
|
||
// NB: simulate a signal coming in by exercising our signal handler | ||
// to avoid complications with sending SIGINFO to the test process | ||
tokio::spawn(async { | ||
wait.await.expect("wait failed"); | ||
send_signal(libc::SIGINFO); | ||
}); | ||
|
||
let _ = fire.send(()); | ||
|
||
// Add a timeout to ensure the test doesn't hang. | ||
timeout(Duration::from_secs(5), sig.recv()) | ||
.await | ||
.expect("received SIGINFO signal in time") | ||
.expect("received SIGINFO signal"); | ||
} |