diff options
Diffstat (limited to 'lib/librthread/rthread_sig.c')
-rw-r--r-- | lib/librthread/rthread_sig.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/lib/librthread/rthread_sig.c b/lib/librthread/rthread_sig.c index eea1306dc49..11351ddafc3 100644 --- a/lib/librthread/rthread_sig.c +++ b/lib/librthread/rthread_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread_sig.c,v 1.10 2011/12/05 04:02:03 guenther Exp $ */ +/* $OpenBSD: rthread_sig.c,v 1.11 2011/12/27 17:36:59 guenther Exp $ */ /* * Copyright (c) 2005 Ted Unangst <tedu@openbsd.org> * All Rights Reserved. @@ -26,6 +26,8 @@ #include "rthread.h" +int _thread_sys_sigprocmask(int, const sigset_t *, sigset_t *); + int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) { @@ -33,13 +35,28 @@ pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) } int +sigprocmask(int how, const sigset_t *set, sigset_t *oset) +{ + sigset_t s; + + if (set != NULL && how != SIG_UNBLOCK && sigismember(set, SIGTHR)) { + s = *set; + sigdelset(&s, SIGTHR); + set = &s; + } + return (_thread_sys_sigprocmask(how, set, oset)); +} + +int sigwait(const sigset_t *set, int *sig) { pthread_t self = pthread_self(); + sigset_t s = *set; int ret; + sigdelset(&s, SIGTHR); _enter_cancel(self); - ret = thrsigdivert(*set, NULL, NULL); + ret = thrsigdivert(s, NULL, NULL); _leave_cancel(self); if (ret == -1) return (errno); @@ -47,3 +64,19 @@ sigwait(const sigset_t *set, int *sig) return (0); } +int +sigaction(int sig, const struct sigaction *act, struct sigaction *oact) +{ + struct sigaction sa; + + if (sig == SIGTHR) { + errno = EINVAL; + return (-1); + } + if (act != NULL && sigismember(&act->sa_mask, SIGTHR)) { + sa = *act; + sigdelset(&sa.sa_mask, SIGTHR); + act = &sa; + } + return (_thread_sys_sigaction(sig, act, oact)); +} |