Print this page
5281 incorrect realtime signal delivery

@@ -18,10 +18,11 @@
  *
  * CDDL HEADER END
  */
 
 /*
+ * Copyright 2014 Ryan Zezeski.  All rights reserved.
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
 #include "lint.h"

@@ -68,10 +69,11 @@
  * Common code for calling the user-specified signal handler.
  */
 void
 call_user_handler(int sig, siginfo_t *sip, ucontext_t *ucp)
 {
+        int i;
         ulwp_t *self = curthread;
         uberdata_t *udp = self->ul_uberdata;
         struct sigaction uact;
         volatile struct sigaction *sap;
 

@@ -153,10 +155,24 @@
                 /* the signal mask at the previous level */
                 sigorset(&uact.sa_mask, &ucp->uc_sigmask);
         }
         if (!(uact.sa_flags & SA_NODEFER))      /* add current signal */
                 (void) sigaddset(&uact.sa_mask, sig);
+
+        /*
+         * Enforce the proper order for realtime signals.  Lower signals
+         * have higher priority and multiple instances of the same signal
+         * must arrive in FIFO order (NODEFER does not apply).
+         *
+         * See section 2.4.2 of POSIX.
+         */
+        if ((sig >= SIGRTMIN) && (sig <= SIGRTMAX)) {
+                for (i = sig; i <= SIGRTMAX; i++) {
+                        (void) sigaddset(&uact.sa_mask, i);
+                }
+        }
+
         self->ul_sigmask = uact.sa_mask;
         self->ul_siglink = ucp;
         (void) __lwp_sigmask(SIG_SETMASK, &uact.sa_mask);
 
         /*