blob: bb8941fadb1954cf9ff80a3a5205616a88132f56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
extern crate nix;
use nix::unistd;
#[cfg(any(target_os = "linux", target_os = "android"))]
use nix::sys::signalfd::*;
#[cfg(any(target_os = "linux", target_os = "android"))]
fn main() {
let mut mask = SigSet::empty();
mask.add(signal::SIGUSR1).unwrap();
mask.thread_block().unwrap();
let mut fd = SignalFd::new(&mask).unwrap();
let pid = unistd::getpid();
signal::kill(pid, signal::SIGUSR1).unwrap();
let res = fd.read_signal();
assert!(res.is_ok());
let opt = res.ok().unwrap();
assert!(opt.is_some());
let info = opt.unwrap();
assert_eq!(info.ssi_signo as i32, signal::SIGUSR1);
}
#[cfg(not(any(target_os = "linux", target_os = "android")))]
fn main() {}
|