From 2d11366fd160ec1dd3918164fa324275e1bab070 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 17 Dec 2025 14:00:56 +1100 Subject: [PATCH] misc(sigabi): `is_parent_sigchld` -> `stop_or_continue` * The original argument `is_parent_sigchld` was misleading as it applied to any `SIGCHLD` sent to the parent (exit and stop/continue). `SA_NOCLDSTOP` should only suppress stop and continue events, not exits. * Document the behaviour. Signed-off-by: Anhad Singh --- src/sigabi.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/sigabi.rs b/src/sigabi.rs index 292eb9ab26..73361a65f8 100644 --- a/src/sigabi.rs +++ b/src/sigabi.rs @@ -133,14 +133,23 @@ impl NonatomicUsize { pub fn sig_bit(sig: usize) -> u64 { 1 << (sig - 1) } + +// TODO: Move to redox_rt? impl SigProcControl { - // TODO: Move to redox_rt? - pub fn signal_will_ign(&self, sig: usize, is_parent_sigchld: bool) -> bool { + /// Checks if `sig` should be ignored based on the current action flags. + /// + /// * `sig` - The signal to check (e.g. `SIGCHLD`). + /// + /// * `stop_or_continue` - Whether the signal is generated because a child + /// process stopped (`SIGSTOP`, `SIGTSTP`) or continued (`SIGCONT`). If + /// `true` and `sig` is `SIGCHLD`, the signal shall not be delivered if the + /// `SA_NOCLDSTOP` flag is set for `SIGCHLD`. + pub fn signal_will_ign(&self, sig: usize, stop_or_continue: bool) -> bool { let flags = self.actions[sig - 1].first.load(Ordering::Relaxed); let will_ign = flags & (1 << 63) != 0; let sig_specific = flags & (1 << 62) != 0; // SA_NOCLDSTOP if sig == SIGCHLD - will_ign || (sig == SIGCHLD && is_parent_sigchld && sig_specific) + will_ign || (sig == SIGCHLD && stop_or_continue && sig_specific) } // TODO: Move to redox_rt? pub fn signal_will_stop(&self, sig: usize) -> bool {