diff --git a/redox-rt/src/signal.rs b/redox-rt/src/signal.rs index b29f9218e7..628e08c53b 100644 --- a/redox-rt/src/signal.rs +++ b/redox-rt/src/signal.rs @@ -351,11 +351,12 @@ fn modify_sigmask(old: Option<&mut u64>, op: Option u64>) -> let next = !op(!prev); - let pending = set_allowset_raw(&ctl.word, prev, next); + let thread_pending = set_allowset_raw(&ctl.word, prev, next); + let proc_pending = PROC_CONTROL_STRUCT.pending.load(Ordering::Relaxed); // POSIX requires that at least one pending unblocked signal be delivered before // pthread_sigmask returns, if there is one. - if pending != 0 { + if (thread_pending | proc_pending) & next != 0 { unsafe { manually_enter_trampoline(); } diff --git a/src/header/signal/mod.rs b/src/header/signal/mod.rs index db7d03da24..e0309b90c0 100644 --- a/src/header/signal/mod.rs +++ b/src/header/signal/mod.rs @@ -387,9 +387,13 @@ pub unsafe extern "C" fn sigpending(set: *mut sigset_t) -> c_int { .or_minus_one_errno() } -const BELOW_SIGRTMIN_MASK: sigset_t = (1 << SIGRTMIN) - 1; -const STANDARD_SIG_MASK: sigset_t = (1 << 32) - 1; -const RLCT_SIGNAL_MASK: sigset_t = BELOW_SIGRTMIN_MASK & !STANDARD_SIG_MASK; +// TODO: Double-check this mask. +// This prevents the application from blocking the two signals SIGRTMIN - 1 and SIGRTMIN - 2 which +// are (at least meant to be) used internally for timers and pthread cancellation. On Linux this is +// 32 and 33 (same as NPTL reserves), whereas this on Redox is 33 and 34 (TODO: could this be +// changed to 32 and 33 for Redox too, since there's currently no support for "sigqueue" targeting +// specific threads). +const RLCT_SIGNAL_MASK: sigset_t = (1 << ((SIGRTMIN - 1) - 1)) | (1 << (SIGRTMIN - 2) - 1); /// See . #[unsafe(no_mangle)] diff --git a/src/platform/redox/signal.rs b/src/platform/redox/signal.rs index 8010d37b92..f25b188a0e 100644 --- a/src/platform/redox/signal.rs +++ b/src/platform/redox/signal.rs @@ -7,8 +7,8 @@ use crate::{ header::{ errno::{EINVAL, ENOSYS}, signal::{ - NSIG, SA_SIGINFO, SIG_BLOCK, SIG_DFL, SIG_IGN, SIG_SETMASK, SIG_UNBLOCK, SIGRTMIN, - SS_DISABLE, SS_ONSTACK, sigaction, siginfo_t, sigset_t, sigval, stack_t, ucontext_t, + NSIG, SA_SIGINFO, SIG_BLOCK, SIG_DFL, SIG_IGN, SIG_SETMASK, SIG_UNBLOCK, SS_DISABLE, + SS_ONSTACK, sigaction, siginfo_t, sigset_t, sigval, stack_t, ucontext_t, }, sys_time::{ITIMER_REAL, itimerval}, time::timespec, @@ -86,18 +86,6 @@ impl PalSignal for Sys { fn raise(sig: c_int) -> Result<()> { // TODO: Bypass kernel? - const n_sig: c_int = NSIG as c_int; - const rt_min: c_int = SIGRTMIN as c_int; - const rt_max: c_int = SIGRTMIN as c_int; - - match sig { - 0..n_sig => {} - rt_min..=rt_max => {} - _ => { - return Err(Errno(EINVAL)); - } - } - unsafe { Self::rlct_kill(Self::current_os_tid(), sig as _) } }