xref: /openbsd/lib/libc/sys/w_sigaction.c (revision 5aed4d28)
1*5aed4d28Sguenther /*	$OpenBSD: w_sigaction.c,v 1.1 2015/10/23 04:39:24 guenther Exp $ */
2*5aed4d28Sguenther /*
3*5aed4d28Sguenther  * Copyright (c) 2005 Ted Unangst <tedu@openbsd.org>
4*5aed4d28Sguenther  * All Rights Reserved.
5*5aed4d28Sguenther  *
6*5aed4d28Sguenther  * Permission to use, copy, modify, and distribute this software for any
7*5aed4d28Sguenther  * purpose with or without fee is hereby granted, provided that the above
8*5aed4d28Sguenther  * copyright notice and this permission notice appear in all copies.
9*5aed4d28Sguenther  *
10*5aed4d28Sguenther  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11*5aed4d28Sguenther  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12*5aed4d28Sguenther  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13*5aed4d28Sguenther  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14*5aed4d28Sguenther  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15*5aed4d28Sguenther  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16*5aed4d28Sguenther  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*5aed4d28Sguenther  */
18*5aed4d28Sguenther /*
19*5aed4d28Sguenther  * signals
20*5aed4d28Sguenther  */
21*5aed4d28Sguenther 
22*5aed4d28Sguenther #include <signal.h>
23*5aed4d28Sguenther #include <errno.h>
24*5aed4d28Sguenther 
25*5aed4d28Sguenther int
WRAP(sigaction)26*5aed4d28Sguenther WRAP(sigaction)(int sig, const struct sigaction *act, struct sigaction *oact)
27*5aed4d28Sguenther {
28*5aed4d28Sguenther 	struct sigaction sa;
29*5aed4d28Sguenther 
30*5aed4d28Sguenther 	if (sig == SIGTHR) {
31*5aed4d28Sguenther 		errno = EINVAL;
32*5aed4d28Sguenther 		return (-1);
33*5aed4d28Sguenther 	}
34*5aed4d28Sguenther 	if (act != NULL && sigismember(&act->sa_mask, SIGTHR)) {
35*5aed4d28Sguenther 		sa = *act;
36*5aed4d28Sguenther 		sigdelset(&sa.sa_mask, SIGTHR);
37*5aed4d28Sguenther 		act = &sa;
38*5aed4d28Sguenther 	}
39*5aed4d28Sguenther 	return (sigaction(sig, act, oact));
40*5aed4d28Sguenther }
41*5aed4d28Sguenther DEF_WRAP(sigaction);
42