diff options
author | Kurt Miller <kurt@cvs.openbsd.org> | 2008-04-24 03:31:34 +0000 |
---|---|---|
committer | Kurt Miller <kurt@cvs.openbsd.org> | 2008-04-24 03:31:34 +0000 |
commit | 6b2473c027f24edba1bdd64ff89b13bec40a3365 (patch) | |
tree | 37e5df3188b3e5bb43236a379e95e6aa30172947 | |
parent | e75ab05ae705cdd8919929a6c26af36867ca408a (diff) |
Return the proper values upon failure per POSIX for pthread_sigmask(3) and
sigprocmask(2) in threaded programs.
From Philip Guenther <guenther at sendmail.com> via PR library/5795.
okay marc@
-rw-r--r-- | lib/libpthread/uthread/uthread_sigmask.c | 5 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_sigprocmask.c | 12 | ||||
-rw-r--r-- | regress/lib/libpthread/sigmask/sigmask.c | 11 |
3 files changed, 19 insertions, 9 deletions
diff --git a/lib/libpthread/uthread/uthread_sigmask.c b/lib/libpthread/uthread/uthread_sigmask.c index 04634a8855d..b33227e2aed 100644 --- a/lib/libpthread/uthread/uthread_sigmask.c +++ b/lib/libpthread/uthread/uthread_sigmask.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_sigmask.c,v 1.7 2003/07/08 00:17:19 marc Exp $ */ +/* $OpenBSD: uthread_sigmask.c,v 1.8 2008/04/24 03:31:33 kurt Exp $ */ /* * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. * All rights reserved. @@ -75,8 +75,7 @@ pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) /* Trap invalid actions: */ default: /* Return an invalid argument: */ - errno = EINVAL; - ret = -1; + ret = EINVAL; break; } diff --git a/lib/libpthread/uthread/uthread_sigprocmask.c b/lib/libpthread/uthread/uthread_sigprocmask.c index ebe56d899b6..658fe84cd9b 100644 --- a/lib/libpthread/uthread/uthread_sigprocmask.c +++ b/lib/libpthread/uthread/uthread_sigprocmask.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_sigprocmask.c,v 1.4 2001/12/30 01:11:07 fgsch Exp $ */ +/* $OpenBSD: uthread_sigprocmask.c,v 1.5 2008/04/24 03:31:33 kurt Exp $ */ /* * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. * All rights reserved. @@ -41,6 +41,14 @@ int sigprocmask(int how, const sigset_t *set, sigset_t *oset) { - return (pthread_sigmask(how, set, oset)); + int ret; + + ret = pthread_sigmask(how, set, oset); + if (ret != 0) + { + errno = ret; + ret = -1; + } + return ret; } #endif diff --git a/regress/lib/libpthread/sigmask/sigmask.c b/regress/lib/libpthread/sigmask/sigmask.c index b3ccc0fa2a4..ccdf5fc5dc3 100644 --- a/regress/lib/libpthread/sigmask/sigmask.c +++ b/regress/lib/libpthread/sigmask/sigmask.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sigmask.c,v 1.2 2003/07/14 22:01:42 marc Exp $ */ +/* $OpenBSD: sigmask.c,v 1.3 2008/04/24 03:31:33 kurt Exp $ */ /* PUBLIC DOMAIN July 2003 Marco S Hyman <marc@snafu.org> */ #include <sys/time.h> @@ -29,7 +29,10 @@ int main (int argc, char *argv[]) /* mask sigalrm */ CHECKe(sigemptyset(&mask)); CHECKe(sigaddset(&mask, SIGALRM)); - CHECKe(pthread_sigmask(SIG_BLOCK, &mask, NULL)); + CHECKr(pthread_sigmask(SIG_BLOCK, &mask, NULL)); + + /* make sure pthread_sigmask() returns the right value on failure */ + CHECKe(pthread_sigmask(-1, &mask, NULL)); /* now trigger sigalrm and wait for it */ printf("trigger sigalrm[2] [masked, test should not die]\n"); @@ -38,7 +41,7 @@ int main (int argc, char *argv[]) /* sigwait for sigalrm, it should be pending. If it is not the test will hang. */ - CHECKe(sigwait(&mask, &sig)); + CHECKr(sigwait(&mask, &sig)); ASSERT(sig == SIGALRM); /* make sure sigwait didn't muck with the mask by triggering @@ -52,7 +55,7 @@ int main (int argc, char *argv[]) is triggered. */ if (argc > 1) { printf("trigger sigalrm[4] [unmasked, test should die]\n"); - CHECKe(pthread_sigmask(SIG_UNBLOCK, &mask, NULL)); + CHECKr(pthread_sigmask(SIG_UNBLOCK, &mask, NULL)); ualarm(100000, 0); CHECKe(sleep(1)); } |