Print this page
5281 incorrect realtime signal delivery

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/port/threads/sigaction.c
          +++ new/usr/src/lib/libc/port/threads/sigaction.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
       23 + * Copyright 2014 Ryan Zezeski.  All rights reserved.
  23   24   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24   25   * Use is subject to license terms.
  25   26   */
  26   27  
  27   28  #include "lint.h"
  28   29  #include <sys/feature_tests.h>
  29   30  /*
  30   31   * setcontext() really can return, if UC_CPU is not specified.
  31   32   * Make the compiler shut up about it.
  32   33   */
↓ open down ↓ 30 lines elided ↑ open up ↑
  63   64  #error "fix me: MAXSIG out of bounds"
  64   65  #endif
  65   66  }
  66   67  
  67   68  /*
  68   69   * Common code for calling the user-specified signal handler.
  69   70   */
  70   71  void
  71   72  call_user_handler(int sig, siginfo_t *sip, ucontext_t *ucp)
  72   73  {
       74 +        int i;
  73   75          ulwp_t *self = curthread;
  74   76          uberdata_t *udp = self->ul_uberdata;
  75   77          struct sigaction uact;
  76   78          volatile struct sigaction *sap;
  77   79  
  78   80          /*
  79   81           * If we are taking a signal while parked or about to be parked
  80   82           * on __lwp_park() then remove ourself from the sleep queue so
  81   83           * that we can grab locks.  The code in mutex_lock_queue() and
  82   84           * cond_wait_common() will detect this and deal with it when
↓ open down ↓ 65 lines elided ↑ open up ↑
 148  150                  ucp->uc_sigmask = self->ul_sigmask;
 149  151                  self->ul_sigsuspend = 0;
 150  152                  /* the sigsuspend() or pollsys() signal mask */
 151  153                  sigorset(&uact.sa_mask, &self->ul_tmpmask);
 152  154          } else {
 153  155                  /* the signal mask at the previous level */
 154  156                  sigorset(&uact.sa_mask, &ucp->uc_sigmask);
 155  157          }
 156  158          if (!(uact.sa_flags & SA_NODEFER))      /* add current signal */
 157  159                  (void) sigaddset(&uact.sa_mask, sig);
      160 +
      161 +        /*
      162 +         * Enforce the proper order for realtime signals.  Lower signals
      163 +         * have higher priority and multiple instances of the same signal
      164 +         * must arrive in FIFO order (NODEFER does not apply).
      165 +         *
      166 +         * See section 2.4.2 of POSIX.
      167 +         */
      168 +        if ((sig >= SIGRTMIN) && (sig <= SIGRTMAX)) {
      169 +                for (i = sig; i <= SIGRTMAX; i++) {
      170 +                        (void) sigaddset(&uact.sa_mask, i);
      171 +                }
      172 +        }
      173 +
 158  174          self->ul_sigmask = uact.sa_mask;
 159  175          self->ul_siglink = ucp;
 160  176          (void) __lwp_sigmask(SIG_SETMASK, &uact.sa_mask);
 161  177  
 162  178          /*
 163  179           * If this thread has been sent SIGCANCEL from the kernel
 164  180           * or from pthread_cancel(), it is being asked to exit.
 165  181           * The kernel may send SIGCANCEL without a siginfo struct.
 166  182           * If the SIGCANCEL is process-directed (from kill() or
 167  183           * sigqueue()), treat it as an ordinary signal.
↓ open down ↓ 599 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX