diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/librthread/rthread.h | 3 | ||||
-rw-r--r-- | lib/librthread/rthread_sig.c | 45 |
2 files changed, 8 insertions, 40 deletions
diff --git a/lib/librthread/rthread.h b/lib/librthread/rthread.h index 1281b0dcece..0d8dafd08cd 100644 --- a/lib/librthread/rthread.h +++ b/lib/librthread/rthread.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread.h,v 1.18 2008/06/05 21:06:11 kurt Exp $ */ +/* $OpenBSD: rthread.h,v 1.19 2008/10/03 04:22:37 guenther Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org> * All Rights Reserved. @@ -119,7 +119,6 @@ struct pthread { struct pthread_attr attr; struct sched_param sched_param; struct rthread_storage *local_storage; - int sigpend; struct rthread_cleanup_fn *cleanup_fns; }; #define THREAD_DONE 0x001 diff --git a/lib/librthread/rthread_sig.c b/lib/librthread/rthread_sig.c index 1591cd87ccf..83dc5eee2b7 100644 --- a/lib/librthread/rthread_sig.c +++ b/lib/librthread/rthread_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread_sig.c,v 1.5 2008/04/24 11:44:26 kurt Exp $ */ +/* $OpenBSD: rthread_sig.c,v 1.6 2008/10/03 04:22:37 guenther Exp $ */ /* * Copyright (c) 2005 Ted Unangst <tedu@openbsd.org> * All Rights Reserved. @@ -42,45 +42,14 @@ pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) return (sigprocmask(how, set, oset) ? errno : 0); } -/* - * implementation of sigwait: - * 1. we install a handler for each masked signal. - * 2. we inform the kernel we are interested in this signal set. - * 3. sleep. the handler will wake us up. - * - * this is atomic because the kernel will only divert one signal - * to a thread until it asks for more. - */ -static void -sigwait_handler(int sig) -{ - pthread_t self = pthread_self(); - self->sigpend = sig; - thrwakeup(&self->sigpend, 0); -} - -typedef void (*sigfn)(int); - int sigwait(const sigset_t *set, int *sig) { - int i; - sigset_t mask = *set; - pthread_t self = pthread_self(); - sigfn oldhandlers[NSIG]; - - for (i = 0; i < NSIG; i++) { - if (mask & (1 << i)) - oldhandlers[i] = signal(i, sigwait_handler); - } - - thrsigdivert(set); - thrsleep(&self->sigpend, 0, NULL); + int ret; - for (i = 0; i < NSIG; i++) { - if (mask & (1 << i)) - signal(i, oldhandlers[i]); - } - *sig = self->sigpend; - return (0); + ret = thrsigdivert(set); + if (ret == -1) + return errno; + *sig = ret; + return 0; } |