mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-27 01:59:38 -05:00
Use sigaction to set SA_RESTART (if appropriate).
Portability of this code needs to tested.
This commit is contained in:
parent
5b4fd50db6
commit
cd5aed0bbe
10 changed files with 54 additions and 13 deletions
|
|
@ -345,7 +345,7 @@ wait4child( int sig )
|
|||
; /* NULL */
|
||||
#endif
|
||||
|
||||
(void) SIGNAL( SIGCHLD, wait4child );
|
||||
(void) SIGNAL_REINSTALL ( SIGCHLD, wait4child );
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ wait4child( int sig )
|
|||
; /* NULL */
|
||||
#endif
|
||||
|
||||
(void) SIGNAL( SIGCHLD, wait4child );
|
||||
(void) SIGNAL_REINSTALL ( SIGCHLD, wait4child );
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -16,10 +16,18 @@
|
|||
#include <signal.h>
|
||||
|
||||
#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 )
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
33
libraries/liblutil/signal.c
Normal file
33
libraries/liblutil/signal.c
Normal file
|
|
@ -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 <ac/signal.h>
|
||||
|
||||
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
|
||||
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -515,7 +515,7 @@ wait4child( int sig )
|
|||
#else
|
||||
(void) wait( NULL );
|
||||
#endif
|
||||
(void) SIGNAL( sig, wait4child );
|
||||
(void) SIGNAL_REINSTALL( sig, wait4child );
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue