diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c index cc3cce2c5a48..67109af088cb 100644 --- a/lib/libc/gen/signal.c +++ b/lib/libc/gen/signal.c @@ -1,4 +1,4 @@ -/* $NetBSD: signal.c,v 1.13 2012/06/25 22:32:44 abs Exp $ */ +/* $NetBSD: signal.c,v 1.14 2016/06/03 23:57:37 christos Exp $ */ /* * Copyright (c) 1985, 1989, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)signal.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: signal.c,v 1.13 2012/06/25 22:32:44 abs Exp $"); +__RCSID("$NetBSD: signal.c,v 1.14 2016/06/03 23:57:37 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -64,3 +64,19 @@ signal(int s, sig_t a) return (SIG_ERR); return (osa.sa_handler); } + +void +(*bsd_signal(int sig, void (*func)(int)))(int) +{ + struct sigaction act, oact; + + act.sa_handler = func; + act.sa_flags = SA_RESTART; + + sigemptyset(&act.sa_mask); + sigaddset(&act.sa_mask, sig); + if (sigaction(sig, &act, &oact) < 0) + return (SIG_ERR); + + return (oact.sa_handler); +} diff --git a/sys/sys/signal.h b/sys/sys/signal.h index bec4aa150f67..3ca3577bdac8 100644 --- a/sys/sys/signal.h +++ b/sys/sys/signal.h @@ -1,4 +1,4 @@ -/* $NetBSD: signal.h,v 1.67 2011/01/10 13:56:44 christos Exp $ */ +/* $NetBSD: signal.h,v 1.68 2016/06/03 23:57:37 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -235,6 +235,7 @@ struct sigevent { */ __BEGIN_DECLS void (*signal(int, void (*)(int)))(int); +void (*bsd_signal(int, void (*)(int)))(int); #if (_POSIX_C_SOURCE - 0) >= 200112L || defined(_NETBSD_SOURCE) int sigqueue(pid_t, int, const union sigval); #endif