signal: Fix compile on Android

Closes alexcrichton/tokio-signal#19
This commit is contained in:
Alex Crichton
2018-09-10 11:30:02 -07:00
committed by Carl Lerche
parent 0df1882f21
commit 8ddebf4309
+13 -3
View File
@@ -138,13 +138,23 @@ fn signal_enable(signal: c_int) -> io::Result<()> {
}
};
unsafe {
#[cfg(target_os = "android")]
fn flags() -> libc::c_ulong {
(libc::SA_RESTART as libc::c_ulong) |
libc::SA_SIGINFO |
(libc::SA_NOCLDSTOP as libc::c_ulong)
}
#[cfg(not(target_os = "android"))]
fn flags() -> c_int {
libc::SA_RESTART |
libc::SA_SIGINFO |
libc::SA_NOCLDSTOP
}
let mut err = None;
siginfo.init.call_once(|| {
let mut new: libc::sigaction = mem::zeroed();
new.sa_sigaction = handler as usize;
new.sa_flags = libc::SA_RESTART |
libc::SA_SIGINFO |
libc::SA_NOCLDSTOP;
new.sa_flags = flags();
if libc::sigaction(signal, &new, &mut *siginfo.prev.get()) != 0 {
err = Some(io::Error::last_os_error());
} else {