diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-06-03 16:20:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-06-03 16:20:39 +0000 |
commit | 9d478a6659b96a8538eced63153c2b979d72a29d (patch) | |
tree | 56b3d53c50626a9d0d26bc7fee20a4b2cfd53d84 /gnu/usr.bin/cvs | |
parent | e593fefba7a40df5e69e4a2f98a4a6641926e149 (diff) |
zero sigaction before use
Diffstat (limited to 'gnu/usr.bin/cvs')
-rw-r--r-- | gnu/usr.bin/cvs/lib/sighandle.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/gnu/usr.bin/cvs/lib/sighandle.c b/gnu/usr.bin/cvs/lib/sighandle.c index 1db41776634..5e552b94f29 100644 --- a/gnu/usr.bin/cvs/lib/sighandle.c +++ b/gnu/usr.bin/cvs/lib/sighandle.c @@ -9,11 +9,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + GNU General Public License for more details. */ /* Written by Paul Sander, HaL Computer Systems, Inc. <paul@hal.com> Brian Berliner <berliner@Sun.COM> added POSIX support */ @@ -30,18 +26,26 @@ * must not themselves make calls to the signal handling * facilities. * - * $CVSid: @(#)sighandle.c 1.13 94/10/07 $ - * *************************************************************************/ #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include "system.h" #include <sys/types.h> #include <stdio.h> #include <signal.h> +/* Add prototype support. */ +#ifndef PROTO +#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) +#define PROTO(ARGS) ARGS +#else +#define PROTO(ARGS) () +#endif +#endif + #ifdef STDC_HEADERS #include <stdlib.h> #else @@ -54,10 +58,6 @@ char *malloc(); #endif /* __STDC__ */ #endif /* STDC_HEADERS */ -#ifdef _MINIX -#undef POSIX /* Minix 1.6 doesn't support POSIX.1 sigaction yet */ -#endif - /* Define the highest signal number (usually) */ #ifndef SIGMAX #define SIGMAX 64 @@ -78,19 +78,19 @@ static struct SIG_hlist **SIG_handlers; /* Define array of default signal vectors */ -#ifdef POSIX +#ifdef POSIX_SIGNALS static struct sigaction *SIG_defaults; #else #ifdef BSD_SIGNALS static struct sigvec *SIG_defaults; #else -static RETSIGTYPE (**SIG_defaults)(); +static RETSIGTYPE (**SIG_defaults) PROTO ((int)); #endif #endif /* Critical section housekeeping */ static int SIG_crSectNest = 0; /* Nesting level */ -#ifdef POSIX +#ifdef POSIX_SIGNALS static sigset_t SIG_crSectMask; /* Signal mask */ #else static int SIG_crSectMask; /* Signal mask */ @@ -103,14 +103,14 @@ static int SIG_crSectMask; /* Signal mask */ static int SIG_init() { int i; -#ifdef POSIX +#ifdef POSIX_SIGNALS sigset_t sigset_test; #endif if (SIG_defaults && SIG_handlers) /* already allocated */ return (0); -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigfillset(&sigset_test); for (i = 1; i < SIGMAX && sigismember(&sigset_test, i) == 1; i++) ; @@ -129,8 +129,8 @@ static int SIG_init() calloc(i, sizeof(struct sigvec)); #else if (!SIG_defaults) - SIG_defaults = (RETSIGTYPE (**)()) - calloc(i, sizeof(RETSIGTYPE (**)())); + SIG_defaults = (RETSIGTYPE (**) PROTO ((int)) ) + calloc(i, sizeof(RETSIGTYPE (**) PROTO ((int)) )); #endif SIG_crSectMask = 0; #endif @@ -144,6 +144,7 @@ static int SIG_init() * The following invokes each signal handler in the reverse order in which * they were registered. */ +static RETSIGTYPE SIG_handle PROTO ((int)); static RETSIGTYPE SIG_handle(sig) int sig; @@ -175,7 +176,7 @@ RETSIGTYPE (*fn)(); { int val; struct SIG_hlist *this; -#ifdef POSIX +#ifdef POSIX_SIGNALS struct sigaction act; sigset_t sigset_mask, sigset_omask; #else @@ -191,7 +192,7 @@ RETSIGTYPE (*fn)(); val = 0; /* Block this signal while we look at handler chain */ -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigemptyset(&sigset_mask); (void) sigaddset(&sigset_mask, sig); (void) sigprocmask(SIG_BLOCK, &sigset_mask, &sigset_omask); @@ -220,19 +221,19 @@ RETSIGTYPE (*fn)(); if (SIG_handlers[sig] == (struct SIG_hlist *) NULL) { -#ifdef POSIX +#ifdef POSIX_SIGNALS + memset(&act, 0, sizeof act); act.sa_handler = SIG_handle; (void) sigemptyset(&act.sa_mask); act.sa_flags = 0; val = sigaction(sig, &act, &SIG_defaults[sig]); #else #ifdef BSD_SIGNALS - bzero((char *)&vec, sizeof(vec)); + memset (&vec, 0, sizeof (vec)); vec.sv_handler = SIG_handle; val = sigvec(sig, &vec, &SIG_defaults[sig]); #else - if ((SIG_defaults[sig] = signal(sig, SIG_handle)) == - (RETSIGTYPE (*)()) -1) + if ((SIG_defaults[sig] = signal(sig, SIG_handle)) == SIG_ERR) val = -1; #endif #endif @@ -257,7 +258,7 @@ RETSIGTYPE (*fn)(); } /* Unblock the signal */ -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigprocmask(SIG_SETMASK, &sigset_omask, NULL); #else #ifdef BSD_SIGNALS @@ -280,7 +281,7 @@ RETSIGTYPE (*fn)(); int val; struct SIG_hlist *this; struct SIG_hlist *last; -#ifdef POSIX +#ifdef POSIX_SIGNALS sigset_t sigset_mask, sigset_omask; #else #ifdef BSD_SIGNALS @@ -295,7 +296,7 @@ RETSIGTYPE (*fn)(); last = (struct SIG_hlist *) NULL; /* Block this signal while we look at handler chain */ -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigemptyset(&sigset_mask); (void) sigaddset(&sigset_mask, sig); (void) sigprocmask(SIG_BLOCK, &sigset_mask, &sigset_omask); @@ -330,21 +331,21 @@ RETSIGTYPE (*fn)(); /* Restore default behavior if there are no registered handlers */ if (SIG_handlers[sig] == (struct SIG_hlist *) NULL) { -#ifdef POSIX +#ifdef POSIX_SIGNALS val = sigaction(sig, &SIG_defaults[sig], (struct sigaction *) NULL); #else #ifdef BSD_SIGNALS val = sigvec(sig, &SIG_defaults[sig], (struct sigvec *) NULL); #else - if (signal(sig, SIG_defaults[sig]) == (RETSIGTYPE (*)()) -1) + if (signal(sig, SIG_defaults[sig]) == SIG_ERR) val = -1; #endif #endif } /* Unblock the signal */ -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigprocmask(SIG_SETMASK, &sigset_omask, NULL); #else #ifdef BSD_SIGNALS @@ -365,7 +366,7 @@ void SIG_beginCrSect() { if (SIG_crSectNest == 0) { -#ifdef POSIX +#ifdef POSIX_SIGNALS sigset_t sigset_mask; (void) sigfillset(&sigset_mask); @@ -394,7 +395,7 @@ void SIG_endCrSect() SIG_crSectNest--; if (SIG_crSectNest == 0) { -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigprocmask(SIG_SETMASK, &SIG_crSectMask, NULL); #else #ifdef BSD_SIGNALS |