]> git.sur5r.net Git - openldap/commitdiff
Reap back-shell children processes using SIGCHLD handler.
authorKurt Zeilenga <kurt@openldap.org>
Fri, 2 Jul 1999 20:57:22 +0000 (20:57 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 2 Jul 1999 20:57:22 +0000 (20:57 +0000)
CHANGES
include/ac/signal.h
servers/slapd/main.c

diff --git a/CHANGES b/CHANGES
index 6c18fbeebf6fcdae19cc6bba302e8e49663a7b48..9cb33fb865710d0985a1ee9683e2d9b52f2e6833 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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
index 3ab614f581d83653c08b875e9d5969f893ab99cf..b19e27643052c79355582cf6cc1501d81e7ad97d 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <signal.h>
 
+#undef SIGNAL
 #ifdef HAVE_SIGSET
 #define SIGNAL sigset
 #else
 #      endif
 #endif
 
+#ifndef LDAP_SIGCHLD
+#ifdef SIGCHLD
+#define LDAP_SIGCHLD SIGCHLD
+#elif SIGCLD
+#define LDAP_SIGCHLD SIGCLD
+#endif
+#endif
+
 #endif /* _AC_SIGNAL_H */
index 4d91ee7847d095323e15df0467a5209321b7a9bf..136d3ec05e0c6dae7828c05e121e7fb4f6202602 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <stdio.h>
 
+#include <ac/errno.h>
 #include <ac/signal.h>
 #include <ac/socket.h>
 #include <ac/string.h>
 #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
 
 /*