From: Kurt Zeilenga Date: Sat, 22 Jul 2000 00:37:51 +0000 (+0000) Subject: Use sigaction to set SA_RESTART (if appropriate). X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~2390 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cd5aed0bbe8e9f3385aff5f218c2e574517d1db0;p=openldap Use sigaction to set SA_RESTART (if appropriate). Portability of this code needs to tested. --- diff --git a/clients/gopher/go500.c b/clients/gopher/go500.c index 51a3dbb903..2b7c4ed675 100644 --- a/clients/gopher/go500.c +++ b/clients/gopher/go500.c @@ -345,7 +345,7 @@ wait4child( int sig ) ; /* NULL */ #endif - (void) SIGNAL( SIGCHLD, wait4child ); + (void) SIGNAL_REINSTALL ( SIGCHLD, wait4child ); } static void diff --git a/clients/gopher/go500gw.c b/clients/gopher/go500gw.c index 4943f97a8d..efe5054d81 100644 --- a/clients/gopher/go500gw.c +++ b/clients/gopher/go500gw.c @@ -371,7 +371,7 @@ wait4child( int sig ) ; /* NULL */ #endif - (void) SIGNAL( SIGCHLD, wait4child ); + (void) SIGNAL_REINSTALL ( SIGCHLD, wait4child ); } static void diff --git a/clients/ud/main.c b/clients/ud/main.c index 97d138fa38..aebf89c4dc 100644 --- a/clients/ud/main.c +++ b/clients/ud/main.c @@ -727,7 +727,7 @@ attn( int sig ) fflush(stdout); printf("\n\n INTERRUPTED!\n"); - (void) SIGNAL (SIGINT, attn); + (void) SIGNAL_REINSTALL (SIGINT, attn); longjmp(env, 1); } @@ -746,6 +746,6 @@ chwinsz( int sig ) col_size = win.ws_col; } - (void) SIGNAL (SIGWINCH, chwinsz); + (void) SIGNAL_REINSTALL (SIGWINCH, chwinsz); } #endif diff --git a/include/ac/signal.h b/include/ac/signal.h index faca4c66ad..a026014921 100644 --- a/include/ac/signal.h +++ b/include/ac/signal.h @@ -16,10 +16,18 @@ #include #undef SIGNAL -#ifdef HAVE_SIGSET + +#if defined( HAVE_SIGACTION ) +#define SIGNAL lutil_sigaction +typedef void (*lutil_sig_t)(int); +LDAP_LUTIL_F(lutil_sig_t) lutil_sigaction( int sig, sig_t func ); +#define SIGNAL_REINSTALL(sig,act) (void)0 +#elif defined( HAVE_SIGSET ) #define SIGNAL sigset +#define SIGNAL_REINSTALL sigset #else #define SIGNAL signal +#define SIGNAL_REINSTALL signal #endif #if !defined( LDAP_SIGUSR1 ) || !defined( LDAP_SIGUSR2 ) diff --git a/libraries/liblutil/Makefile.in b/libraries/liblutil/Makefile.in index 7baa43eb98..bb85c616c9 100644 --- a/libraries/liblutil/Makefile.in +++ b/libraries/liblutil/Makefile.in @@ -13,11 +13,11 @@ NT_OBJS = ntservice.o slapdmsg.res UNIX_SRCS = detach.c UNIX_OBJS = detach.o -SRCS = base64.c debug.c entropy.c sasl.c \ +SRCS = base64.c debug.c entropy.c sasl.c signal.c \ md5.c passwd.c sha1.c getpass.c lockf.c utils.c sockpair.c \ @LIBSRCS@ $(@PLAT@_SRCS) -OBJS = base64.o debug.o entropy.o sasl.o \ +OBJS = base64.o debug.o entropy.o sasl.o signal.o \ md5.o passwd.o sha1.o getpass.o lockf.o utils.o sockpair.o \ @LIBOBJS@ $(@PLAT@_OBJS) diff --git a/libraries/liblutil/signal.c b/libraries/liblutil/signal.c new file mode 100644 index 0000000000..230a265b95 --- /dev/null +++ b/libraries/liblutil/signal.c @@ -0,0 +1,33 @@ +/* $OpenLDAP$ */ +/* + * Copyright 2000 The OpenLDAP Foundation + * COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory + * of this package for details. + */ + +#include "portable.h" + +#ifdef HAVE_SIGACTION +#include + +lutil_sig_t +lutil_sigaction(int sig, lutil_sig_t func) +{ + int rc; + struct sigaction action, oaction; + + memset( &action, '\0', sizeof(action) ); + + action.sa_handler = func; + sigemptyset( &action.sa_mask ); +#ifdef SA_RESTART + action.sa_flags != SA_RESTART; +#endif + + if( sigaction( sig, &action, &oaction ) != 0 ) { + return NULL; + } + + return oaction.sa_handler; +} +#endif diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 8f50d623d1..671648a5bd 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -1276,7 +1276,7 @@ slap_sig_shutdown( int sig ) WAKE_LISTENER(1); /* reinstall self */ - (void) SIGNAL( sig, slap_sig_shutdown ); + (void) SIGNAL_REINSTALL( sig, slap_sig_shutdown ); } RETSIGTYPE @@ -1285,5 +1285,5 @@ slap_sig_wake( int sig ) WAKE_LISTENER(1); /* reinstall self */ - (void) SIGNAL( sig, slap_sig_wake ); + (void) SIGNAL_REINSTALL( sig, slap_sig_wake ); } diff --git a/servers/slapd/main.c b/servers/slapd/main.c index d1cde5e959..c9d765b0c8 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -515,7 +515,7 @@ wait4child( int sig ) #else (void) wait( NULL ); #endif - (void) SIGNAL( sig, wait4child ); + (void) SIGNAL_REINSTALL( sig, wait4child ); errno = save_errno; } diff --git a/servers/slurpd/admin.c b/servers/slurpd/admin.c index d3017932e1..5425258fad 100644 --- a/servers/slurpd/admin.c +++ b/servers/slurpd/admin.c @@ -40,5 +40,5 @@ RETSIGTYPE do_admin( int sig ) { sglob->rq->rq_dump( sglob->rq ); - (void) SIGNAL( sig, do_admin ); + (void) SIGNAL_REINSTALL( sig, do_admin ); } diff --git a/servers/slurpd/fm.c b/servers/slurpd/fm.c index 75c1afed02..90b89bbe1c 100644 --- a/servers/slurpd/fm.c +++ b/servers/slurpd/fm.c @@ -144,7 +144,7 @@ set_shutdown(int sig) (sglob->replicas[ i ])->ri_wake( sglob->replicas[ i ]); } sglob->rq->rq_unlock( sglob->rq ); /* unlock queue */ - (void) SIGNAL( sig, set_shutdown ); /* reinstall handlers */ + (void) SIGNAL_REINSTALL( sig, set_shutdown ); /* reinstall handlers */ } @@ -156,7 +156,7 @@ set_shutdown(int sig) RETSIGTYPE do_nothing(int sig) { - (void) SIGNAL( sig, do_nothing ); + (void) SIGNAL_REINSTALL( sig, do_nothing ); }