From 8ddebf430999a07286a4d0c7e7da66e43ff09609 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 31 Jan 2018 07:05:26 -0800 Subject: [PATCH] signal: Fix compile on Android Closes alexcrichton/tokio-signal#19 --- src/unix.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/unix.rs b/src/unix.rs index 8ad08c4e7..34d59dc22 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -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 {