From da41bee9591d194a273e3f4bb5ce055bcbadbad9 Mon Sep 17 00:00:00 2001 From: guanyi Date: Mon, 3 Jul 2023 16:27:59 +0800 Subject: [PATCH] ltp: sigprocmask fix 1. change signal/sig_procmask.c and pthread/pthread_sigmask.c together 2. clear signals unconditionally Signed-off-by: guanyi --- sched/pthread/pthread_sigmask.c | 15 ++++++++++++++- sched/signal/sig_procmask.c | 11 +++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/sched/pthread/pthread_sigmask.c b/sched/pthread/pthread_sigmask.c index 25678d0a37a4a..49a979c8b2461 100644 --- a/sched/pthread/pthread_sigmask.c +++ b/sched/pthread/pthread_sigmask.c @@ -64,6 +64,19 @@ int pthread_sigmask(int how, FAR const sigset_t *set, FAR sigset_t *oset) { - int ret = nxsig_procmask(how, set, oset); + sigset_t nset; + int ret; + + /* SIGKILL and SIGSTOP should not be added to signal mask */ + + if (set != NULL) + { + nset = *set; + nxsig_delset(&nset, SIGKILL); + nxsig_delset(&nset, SIGSTOP); + set = &nset; + } + + ret = nxsig_procmask(how, set, oset); return ret < 0 ? -ret : OK; } diff --git a/sched/signal/sig_procmask.c b/sched/signal/sig_procmask.c index 092273544fbc7..c8aeac235278d 100644 --- a/sched/signal/sig_procmask.c +++ b/sched/signal/sig_procmask.c @@ -187,8 +187,19 @@ int nxsig_procmask(int how, FAR const sigset_t *set, FAR sigset_t *oset) int sigprocmask(int how, FAR const sigset_t *set, FAR sigset_t *oset) { + sigset_t nset; int ret; + /* SIGKILL and SIGSTOP should not be added to signal mask */ + + if (set != NULL) + { + nset = *set; + nxsig_delset(&nset, SIGKILL); + nxsig_delset(&nset, SIGSTOP); + set = &nset; + } + /* Let nxsig_procmask do all of the work */ ret = nxsig_procmask(how, set, oset);