diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2003-08-25 01:16:21 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2003-08-25 01:16:21 +0000 |
commit | 5ade9abc37df3dacacbe20104877ca6dab61082a (patch) | |
tree | b3a521b87d93ecc0f1f17f4e659c1d4bf90f86f5 /openbsd-compat/bsd-misc.c | |
parent | af4a6c3a5619299a16cfbb545cde110849596204 (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/bsd-misc.c')
-rw-r--r-- | openbsd-compat/bsd-misc.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index 56cb45ade..08b089bdc 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | #include "xmalloc.h" | 26 | #include "xmalloc.h" |
27 | 27 | ||
28 | RCSID("$Id: bsd-misc.c,v 1.18 2003/08/21 23:34:42 djm Exp $"); | 28 | RCSID("$Id: bsd-misc.c,v 1.19 2003/08/25 01:16:21 mouring Exp $"); |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * NB. duplicate __progname in case it is an alias for argv[0] | 31 | * NB. duplicate __progname in case it is an alias for argv[0] |
@@ -200,3 +200,29 @@ tcsendbreak(int fd, int duration) | |||
200 | # endif | 200 | # endif |
201 | } | 201 | } |
202 | #endif /* HAVE_TCSENDBREAK */ | 202 | #endif /* HAVE_TCSENDBREAK */ |
203 | |||
204 | mysig_t | ||
205 | mysignal(int sig, mysig_t act) | ||
206 | { | ||
207 | #ifdef HAVE_SIGACTION | ||
208 | struct sigaction sa, osa; | ||
209 | |||
210 | if (sigaction(sig, NULL, &osa) == -1) | ||
211 | return (mysig_t) -1; | ||
212 | if (osa.sa_handler != act) { | ||
213 | memset(&sa, 0, sizeof(sa)); | ||
214 | sigemptyset(&sa.sa_mask); | ||
215 | sa.sa_flags = 0; | ||
216 | #ifdef SA_INTERRUPT | ||
217 | if (sig == SIGALRM) | ||
218 | sa.sa_flags |= SA_INTERRUPT; | ||
219 | #endif | ||
220 | sa.sa_handler = act; | ||
221 | if (sigaction(sig, &sa, NULL) == -1) | ||
222 | return (mysig_t) -1; | ||
223 | } | ||
224 | return (osa.sa_handler); | ||
225 | #else | ||
226 | return (signal(sig, act)); | ||
227 | #endif | ||
228 | } | ||