1212405Sdavidxu/*-
2212405Sdavidxu * Copyright (c) 2010 davidxu@freebsd.org
3212405Sdavidxu *
4212405Sdavidxu * Redistribution and use in source and binary forms, with or without
5212405Sdavidxu * modification, are permitted provided that the following conditions
6212405Sdavidxu * are met:
7212405Sdavidxu * 1. Redistributions of source code must retain the above copyright
8212405Sdavidxu *    notice, this list of conditions and the following disclaimer.
9212405Sdavidxu * 2. Redistributions in binary form must reproduce the above copyright
10212405Sdavidxu *    notice, this list of conditions and the following disclaimer in the
11212405Sdavidxu *    documentation and/or other materials provided with the distribution.
12212405Sdavidxu *
13212405Sdavidxu * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14212405Sdavidxu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15212405Sdavidxu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16212405Sdavidxu * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17212405Sdavidxu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18212405Sdavidxu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19212405Sdavidxu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20212405Sdavidxu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21212405Sdavidxu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22212405Sdavidxu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23212405Sdavidxu * SUCH DAMAGE.
24212405Sdavidxu */
25212405Sdavidxu
26212405Sdavidxu#include <sys/cdefs.h>
27212405Sdavidxu__FBSDID("$FreeBSD$");
28212405Sdavidxu
29212405Sdavidxu#include <errno.h>
30212405Sdavidxu#include <signal.h>
31276630Skib#include "libc_private.h"
32212405Sdavidxu
33276630Skib__weak_reference(__libc_sigwait, __sigwait);
34212405Sdavidxu
35276630Skib#pragma weak sigwait
36276630Skibint
37276630Skibsigwait(const sigset_t *set, int *sig)
38276630Skib{
39212405Sdavidxu
40276630Skib	return (((int (*)(const sigset_t *, int *))
41276630Skib	    __libc_interposing[INTERPOS_sigwait])(set, sig));
42276630Skib}
43276630Skib
44212405Sdavidxuint
45276630Skib__libc_sigwait(const sigset_t *set, int *sig)
46212405Sdavidxu{
47212405Sdavidxu	int ret;
48212405Sdavidxu
49212405Sdavidxu	/* POSIX does not allow EINTR to be returned */
50212405Sdavidxu	do  {
51212405Sdavidxu		ret = __sys_sigwait(set, sig);
52212405Sdavidxu	} while (ret == EINTR);
53212405Sdavidxu	return (ret);
54212405Sdavidxu}
55