Issue 99 - slapd creates zombie processes with shell backend
Summary: slapd creates zombie processes with shell backend
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1999-03-10 14:59 UTC by michael@roka.net
Modified: 2014-08-01 21:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description michael@roka.net 1999-03-10 14:59:07 UTC
Full_Name: Michael Haardt
Version: OPENLDAP_REL_ENG_1_2
OS: Linux
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (194.97.109.109)


slapd does not appear to wait for created processes, so each request causes a
zombie.
Comment 1 Hallvard Furuseth 1999-03-11 21:11:33 UTC
michael@roka.net writes:
> slapd does not appear to wait for created processes, so each request
> causes a zombie.

Try this.

*** servers/slapd/main.c	1999/03/09 06:15:35	1.41
--- servers/slapd/main.c	1999/03/11 21:14:35
***************
*** 8,11 ****
--- 8,14 ----
  #include <ac/time.h>
  #include <ac/unistd.h>
+ #include <ac/wait.h>
+ #include <ac/signal.h>
+ #include <ac/errno.h>
  
  #include "ldapconfig.h"
***************
*** 13,16 ****
--- 16,21 ----
  #include "lutil.h"			/* Get lutil_detach() */
  
+ static RETSIGTYPE wait4child( int sig );
+ 
  /*
   * when more than one slapd is running on one machine, each one might have
***************
*** 189,192 ****
--- 194,209 ----
  	}
  
+ 	if ( ! inetd ) {
+ 		/*
+ 		 * Done early in case a backend needs to set up its own
+ 		 * signal handler
+ 		 */
+ #ifdef SIGCHLD
+ 		signal( SIGCHLD, wait4child );
+ #else
+ 		signal( SIGCLD, wait4child );
+ #endif
+ 	}
+ 
  	if ( read_config( configfile ) != 0 ) {
  		rc = 1;
***************
*** 330,333 ****
--- 347,363 ----
  
  
+ static RETSIGTYPE
+ wait4child( int sig )
+ {
+ #if defined(HAVE_WAITPID) && defined(WNOHANG)
+     while ( waitpid( (pid_t)-1, NULL, WNOHANG ) >= 0 || errno == EINTR )
+ 	;	/* NULL */
+ #else
+     (void) wait( NULL );
+ #endif
+     (void) signal( sig, wait4child );
+ }
+ 
+ 
  #ifdef LOG_LOCAL4
  
-- 
Hallvard
Comment 2 Hallvard Furuseth 1999-03-11 21:24:16 UTC
changed notes
moved from Incoming to Software Bugs
Comment 3 michael@roka.net 1999-03-15 13:15:37 UTC
> michael@roka.net writes:
> > slapd does not appear to wait for created processes, so each request
> > causes a zombie.
>
> Try this.
> [patch deleted]

Thanks, I applied the patch and it works fine.  I am surprised that the
exit status is obviously not checked, but it does of course solve the
zombie problem to wait for a child each time one terminates.

Michael
Comment 4 Hallvard Furuseth 1999-03-16 06:18:00 UTC
michael@roka.net writes:
> Thanks, I applied the patch and it works fine.  I am surprised that the
> exit status is obviously not checked, but it does of course solve the
> zombie problem to wait for a child each time one terminates.

Yes, back-shell could use some improvement - which means it needs
someone to improve it.  Feel free to contribute a fix...

-- 
Hallvard
Comment 5 Kurt Zeilenga 1999-03-26 19:01:07 UTC
changed notes
Comment 6 Kurt Zeilenga 1999-03-26 19:01:32 UTC
changed state Open to Test
Comment 7 Hallvard Furuseth 1999-03-27 15:17:42 UTC
A somewhat modified patch is committed to -devel.
I'd be happy if someone could tell me when to use waitpid and when
to use wait3, though.
Comment 8 Kurt Zeilenga 1999-04-01 07:23:04 UTC
changed state Test to Release
Comment 9 Kurt Zeilenga 1999-04-01 07:23:29 UTC
changed state Release to Test
Comment 10 Kurt Zeilenga 1999-04-01 07:24:34 UTC
changed state Test to Closed
Comment 11 OpenLDAP project 2014-08-01 21:06:52 UTC
Patch needs to be applied to rel eng 1.2.