You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/03/31 21:27:10 UTC

[incubator-nuttx] branch master updated: sched/signal: Implement SA_NODEFER and SA_RESETHAND

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new bea6e0d  sched/signal: Implement SA_NODEFER and SA_RESETHAND
bea6e0d is described below

commit bea6e0ddd78a3d56a5fcc54b64983dbb286b8a54
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Mar 26 18:15:17 2021 +0800

    sched/signal: Implement SA_NODEFER and SA_RESETHAND
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: I9baa72b272c8877022cd94722824f393c7087721
---
 include/signal.h            | 8 ++++++++
 sched/signal/sig_deliver.c  | 3 +--
 sched/signal/sig_dispatch.c | 5 +++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/include/signal.h b/include/signal.h
index 269917c..6c113f9 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -249,6 +249,14 @@
                                   * (always assumed) */
 #define SA_NOCLDWAIT    (1 << 2) /* If signo=SIGCHLD, exit status of child
                                   * processes will be discarded */
+#define SA_ONSTACK      (1 << 3) /* Indicates that a registered stack_t
+                                  * will be used */
+#define SA_RESTART      (1 << 4) /* Flag to get restarting signals
+                                  * (which were the default long ago) */
+#define SA_NODEFER      (1 << 5) /* Prevents the current signal from
+                                  * being masked in the handler */
+#define SA_RESETHAND    (1 << 6) /* Clears the handler when the signal
+                                  * is delivered */
 
 /* These are the possible values of the signfo si_code field */
 
diff --git a/sched/signal/sig_deliver.c b/sched/signal/sig_deliver.c
index d8b894e..d0739f9 100644
--- a/sched/signal/sig_deliver.c
+++ b/sched/signal/sig_deliver.c
@@ -106,8 +106,7 @@ void nxsig_deliver(FAR struct tcb_s *stcb)
        */
 
       savesigprocmask   = stcb->sigprocmask;
-      newsigprocmask    = savesigprocmask | sigq->mask |
-                          SIGNO2SET(sigq->info.si_signo);
+      newsigprocmask    = savesigprocmask | sigq->mask;
       stcb->sigprocmask = newsigprocmask;
 
 #ifndef CONFIG_BUILD_FLAT
diff --git a/sched/signal/sig_dispatch.c b/sched/signal/sig_dispatch.c
index 67b46fa..a07fd0e 100644
--- a/sched/signal/sig_dispatch.c
+++ b/sched/signal/sig_dispatch.c
@@ -93,6 +93,11 @@ static int nxsig_queue_action(FAR struct tcb_s *stcb, siginfo_t *info)
 
           sigq->action.sighandler = sigact->act.sa_u._sa_sigaction;
           sigq->mask = sigact->act.sa_mask;
+          if ((sigact->act.sa_flags & SA_NODEFER) == 0)
+            {
+              sigq->mask |= SIGNO2SET(info->si_signo);
+            }
+
           memcpy(&sigq->info, info, sizeof(siginfo_t));
 
           /* Put it at the end of the pending signals list */