aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/stdlib/Makefile.inc2
-rw-r--r--lib/libc/sys/Makefile.inc3
-rw-r--r--lib/libc/sys/Symbol.map1
-rw-r--r--lib/libc/sys/sigwait.c46
-rw-r--r--lib/libthr/thread/thr_sig.c14
5 files changed, 59 insertions, 7 deletions
diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc
index 3627294d0b3b..ee4c4e22e20e 100644
--- a/lib/libc/stdlib/Makefile.inc
+++ b/lib/libc/stdlib/Makefile.inc
@@ -9,7 +9,7 @@ MISRCS+=_Exit.c a64l.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \
getsubopt.c hcreate.c heapsort.c imaxabs.c imaxdiv.c \
insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c malloc.c \
merge.c ptsname.c qsort.c qsort_r.c radixsort.c rand.c random.c \
- reallocf.c realpath.c remque.c strfmon.c strtoimax.c \
+ reallocf.c realpath.c remque.c sigwait.c strfmon.c strtoimax.c \
strtol.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \
strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 9876bdec34e2..09d40166825d 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -21,6 +21,9 @@ SRCS+= stack_protector.c stack_protector_compat.c __error.c
SRCS+= fcntl.c ftruncate.c lseek.c mmap.c pread.c pwrite.c truncate.c
PSEUDO+= _fcntl.o
.endif
+SRCS+= sigwait.c
+NOASM+= sigwait.o
+PSEUDO+= _sigwait.o
# Add machine dependent asm sources:
SRCS+=${MDASM}
diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map
index ce6f32a675c5..74751f9f297d 100644
--- a/lib/libc/sys/Symbol.map
+++ b/lib/libc/sys/Symbol.map
@@ -919,6 +919,7 @@ FBSDprivate_1.0 {
_sigtimedwait;
__sys_sigtimedwait;
_sigwait;
+ __sigwait;
__sys_sigwait;
_sigwaitinfo;
__sys_sigwaitinfo;
diff --git a/lib/libc/sys/sigwait.c b/lib/libc/sys/sigwait.c
new file mode 100644
index 000000000000..2fdffdd06db8
--- /dev/null
+++ b/lib/libc/sys/sigwait.c
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2010 davidxu@freebsd.org
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <errno.h>
+#include <signal.h>
+
+int __sys_sigwait(const sigset_t * restrict, int * restrict);
+
+__weak_reference(__sigwait, sigwait);
+
+int
+__sigwait(const sigset_t * restrict set, int * restrict sig)
+{
+ int ret;
+
+ /* POSIX does not allow EINTR to be returned */
+ do {
+ ret = __sys_sigwait(set, sig);
+ } while (ret == EINTR);
+ return (ret);
+}
diff --git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c
index 5067e646dcad..7bff32b6ddde 100644
--- a/lib/libthr/thread/thr_sig.c
+++ b/lib/libthr/thread/thr_sig.c
@@ -67,7 +67,7 @@ int _sigtimedwait(const sigset_t *set, siginfo_t *info,
const struct timespec * timeout);
int __sigwaitinfo(const sigset_t *set, siginfo_t *info);
int _sigwaitinfo(const sigset_t *set, siginfo_t *info);
-int __sigwait(const sigset_t *set, int *sig);
+int ___sigwait(const sigset_t *set, int *sig);
int _sigwait(const sigset_t *set, int *sig);
int __sigsuspend(const sigset_t *sigmask);
int _sigaction(int, const struct sigaction *, struct sigaction *);
@@ -634,7 +634,7 @@ __sigsuspend(const sigset_t * set)
return (ret);
}
-__weak_reference(__sigwait, sigwait);
+__weak_reference(___sigwait, sigwait);
__weak_reference(__sigtimedwait, sigtimedwait);
__weak_reference(__sigwaitinfo, sigwaitinfo);
@@ -708,15 +708,17 @@ _sigwait(const sigset_t *set, int *sig)
* it is not canceled.
*/
int
-__sigwait(const sigset_t *set, int *sig)
+___sigwait(const sigset_t *set, int *sig)
{
struct pthread *curthread = _get_curthread();
sigset_t newset;
int ret;
- _thr_cancel_enter(curthread);
- ret = __sys_sigwait(thr_remove_thr_signals(set, &newset), sig);
- _thr_cancel_leave(curthread, (ret != 0));
+ do {
+ _thr_cancel_enter(curthread);
+ ret = __sys_sigwait(thr_remove_thr_signals(set, &newset), sig);
+ _thr_cancel_leave(curthread, (ret != 0));
+ } while (ret == EINTR);
return (ret);
}