Commit 352e8eba authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Reap back-shell children processes using SIGCHLD handler.

parent a6883d27
......@@ -3,6 +3,7 @@ OpenLDAP Change Log
Changes included in OpenLDAP 1.2 Release Engineering
CVS Tag: OPENLDAP_REL_ENG_1_2
Added the MDBM to the ldbm backends (memory mapped dbm)
Fixed slapd to reap back-shell children processes
Updated README to require BerkeleyDB 2.7.5
Fixed incorrect schema check when objectclass is missing (ITS#204)
Build environment
......
......@@ -14,6 +14,7 @@
#include <signal.h>
#undef SIGNAL
#ifdef HAVE_SIGSET
#define SIGNAL sigset
#else
......@@ -52,4 +53,12 @@
# endif
#endif
#ifndef LDAP_SIGCHLD
#ifdef SIGCHLD
#define LDAP_SIGCHLD SIGCHLD
#elif SIGCLD
#define LDAP_SIGCHLD SIGCLD
#endif
#endif
#endif /* _AC_SIGNAL_H */
......@@ -2,6 +2,7 @@
#include <stdio.h>
#include <ac/errno.h>
#include <ac/signal.h>
#include <ac/socket.h>
#include <ac/string.h>
......@@ -12,6 +13,10 @@
#include "slap.h"
#include "lutil.h" /* Get lutil_detach() */
#ifdef LDAP_SIGCHLD
static void wait4child( int sig );
#endif
/*
* when more than one slapd is running on one machine, each one might have
* it's own LOCAL for syslogging and must have its own pid/args files
......@@ -197,6 +202,9 @@ main( int argc, char **argv )
(void) SIGNAL( SIGTERM, slap_set_shutdown );
(void) SIGNAL( SIGINT, slap_set_shutdown );
(void) SIGNAL( SIGHUP, slap_set_shutdown );
#ifdef LDAP_SIGCHLD
(void) SIGNAL( LDAP_SIGCHLD, wait4child );
#endif
time( &starttime );
......@@ -295,6 +303,36 @@ main( int argc, char **argv )
}
#ifdef LDAP_SIGCHLD
/*
* Catch and discard terminated child processes, to avoid zombies.
*/
static void
wait4child( int sig )
{
int save_errno = errno;
#ifdef WNOHANG
errno = 0;
#ifdef HAVE_WAITPID
while ( waitpid( (pid_t)-1, NULL, WNOHANG ) >= 0 || errno == EINTR )
; /* NULL */
#else
while ( wait3( NULL, WNOHANG, NULL ) >= 0 || errno == EINTR )
; /* NULL */
#endif
#else
(void) wait( NULL );
#endif
(void) SIGNAL( sig, wait4child );
errno = save_errno;
}
#endif /* SIGCHLD || SIGCLD */
#ifdef LOG_LOCAL4
/*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment