summaryrefslogtreecommitdiffstats
path: root/openbsd-compat
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2003-08-25 01:16:21 +0000
committerBen Lindstrom <mouring@eviladmin.org>2003-08-25 01:16:21 +0000
commit5ade9abc37df3dacacbe20104877ca6dab61082a (patch)
treeb3a521b87d93ecc0f1f17f4e659c1d4bf90f86f5 /openbsd-compat
parentaf4a6c3a5619299a16cfbb545cde110849596204 (diff)
- (bal) redo how we handle 'mysignal()'. Move it to
openbsd-compat/bsd-misc.c, s/mysignal/signal/ and #define signal to be our 'mysignal' by default. OK djm@
Diffstat (limited to 'openbsd-compat')
-rw-r--r--openbsd-compat/bsd-misc.c28
-rw-r--r--openbsd-compat/bsd-misc.h8
2 files changed, 34 insertions, 2 deletions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 56cb45ad..08b089bd 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -25,7 +25,7 @@
#include "includes.h"
#include "xmalloc.h"
-RCSID("$Id: bsd-misc.c,v 1.18 2003/08/21 23:34:42 djm Exp $");
+RCSID("$Id: bsd-misc.c,v 1.19 2003/08/25 01:16:21 mouring Exp $");
/*
* NB. duplicate __progname in case it is an alias for argv[0]
@@ -200,3 +200,29 @@ tcsendbreak(int fd, int duration)
# endif
}
#endif /* HAVE_TCSENDBREAK */
+
+mysig_t
+mysignal(int sig, mysig_t act)
+{
+#ifdef HAVE_SIGACTION
+ struct sigaction sa, osa;
+
+ if (sigaction(sig, NULL, &osa) == -1)
+ return (mysig_t) -1;
+ if (osa.sa_handler != act) {
+ memset(&sa, 0, sizeof(sa));
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+#ifdef SA_INTERRUPT
+ if (sig == SIGALRM)
+ sa.sa_flags |= SA_INTERRUPT;
+#endif
+ sa.sa_handler = act;
+ if (sigaction(sig, &sa, NULL) == -1)
+ return (mysig_t) -1;
+ }
+ return (osa.sa_handler);
+#else
+ return (signal(sig, act));
+#endif
+}
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index 2857de59..0d6076ab 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -22,7 +22,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $Id: bsd-misc.h,v 1.11 2003/08/21 23:34:42 djm Exp $ */
+/* $Id: bsd-misc.h,v 1.12 2003/08/25 01:16:22 mouring Exp $ */
#ifndef _BSD_MISC_H
#define _BSD_MISC_H
@@ -97,4 +97,10 @@ pid_t tcgetpgrp(int);
int tcsendbreak(int, int);
#endif
+/* wrapper for signal interface */
+typedef void (*mysig_t)(int);
+mysig_t mysignal(int sig, mysig_t act);
+
+#define signal(a,b) mysignal(a,b)
+
#endif /* _BSD_MISC_H */