Index: thread/thr_sigmask.c =================================================================== RCS file: /opt/FreeBSD/cvs/src/lib/libpthread/thread/thr_sigmask.c,v retrieving revision 1.19 diff -u -r1.19 thr_sigmask.c --- thread/thr_sigmask.c 18 Sep 2003 12:19:28 -0000 1.19 +++ thread/thr_sigmask.c 9 May 2005 23:20:38 -0000 @@ -42,6 +42,44 @@ __weak_reference(_pthread_sigmask, pthread_sigmask); + +static int +compute_mask(int how, const sigset_t *set, sigset_t *newset) +{ + int ret; + + ret = 0; + + /* Process according to what to do: */ + switch (how) { + /* Block signals: */ + case SIG_BLOCK: + /* Add signals to the existing mask: */ + SIGSETOR(*newset, *set); + break; + + /* Unblock signals: */ + case SIG_UNBLOCK: + /* Clear signals from the existing mask: */ + SIGSETNAND(*newset, *set); + break; + + /* Set the signal process mask: */ + case SIG_SETMASK: + /* Set the new mask: */ + *newset = *set; + break; + + /* Trap invalid actions: */ + default: + /* Return an invalid argument: */ + ret = EINVAL; + break; + } + SIG_CANTMASK(*newset); + return (ret); +} + int _pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) { @@ -53,11 +91,14 @@ ret = __sys_sigprocmask(how, set, oset); if (ret != 0) ret = errno; - /* Get a fresh copy */ - __sys_sigprocmask(SIG_SETMASK, NULL, &curthread->sigmask); + else { + /* Get a fresh copy */ + ret = compute_mask(how, set, &curthread->sigmask); + } return (ret); } + /* Check for bad address before taking the lock. */ if (set) newset = *set; @@ -70,33 +111,7 @@ /* Check if a new signal set was provided by the caller: */ if (set != NULL) { - /* Process according to what to do: */ - switch (how) { - /* Block signals: */ - case SIG_BLOCK: - /* Add signals to the existing mask: */ - SIGSETOR(curthread->sigmask, newset); - break; - - /* Unblock signals: */ - case SIG_UNBLOCK: - /* Clear signals from the existing mask: */ - SIGSETNAND(curthread->sigmask, newset); - break; - - /* Set the signal process mask: */ - case SIG_SETMASK: - /* Set the new mask: */ - curthread->sigmask = newset; - break; - - /* Trap invalid actions: */ - default: - /* Return an invalid argument: */ - ret = EINVAL; - break; - } - SIG_CANTMASK(curthread->sigmask); + ret = compute_mask(how, set, &curthread->sigmask); THR_SCHED_UNLOCK(curthread, curthread); /*