From 8cca30b44cf6b539552feee4b4f713198f8fcce2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 16 May 2023 10:46:39 -0600 Subject: [PATCH] Signal must be masked when it is delivered to a signal handler Signal must be masked when it is delivered to a signal handler per: https://pubs.opengroup.org/onlinepubs/007904875/functions/sigaction.html: When a signal is caught by a signal-catching function installed by sigaction(), a new signal mask is calculated and installed for the duration of the signal-catching function (or until a call to either sigprocmask() or sigsuspend() is made). This mask is formed by taking the union of the current signal mask and the value of the sa_mask for the signal being delivered [XSI] [Option Start] unless SA_NODEFER or SA_RESETHAND is set, [Option End] and then including the signal being delivered. If and when the user's signal handler returns normally, the original signal mask is restored. Any action queued for that signal while the signal is masked should be deferred. It should go into the group pending signal list and should not be processed until until the signal is unmasked (which should occur when the signal handler returns). --- sched/signal/sig_deliver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sched/signal/sig_deliver.c b/sched/signal/sig_deliver.c index da6cac89d4..d6970ef8b1 100644 --- a/sched/signal/sig_deliver.c +++ b/sched/signal/sig_deliver.c @@ -117,6 +117,7 @@ void nxsig_deliver(FAR struct tcb_s *stcb) savesigprocmask = stcb->sigprocmask; sigorset(&newsigprocmask, &savesigprocmask, &sigq->mask); + nxsig_addset(&newsigprocmask, sigq->info.si_signo); stcb->sigprocmask = newsigprocmask; #ifndef CONFIG_BUILD_FLAT