[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Can't kill idle slapds on FreeBSD 4.0

Bryan Mawhinney wrote:
> I recently installed OpenLdap 1.2.10 on FreeBSD 4.0-RELEASE
> (via /usr/ports), and I've noticed that idle slapd processes
> don't respond to SIGTERM.  I think this comes down to the
> following section of daemon.c:
> tvp = active_threads ? &zero : NULL
> ..
> switch ( i = select( dtblsize, &readfds, &writefds, 0, tvp) ) {
> If active_threads is 0, tvp is set to NULL and the select
> seems to block forever.  Is this accurate?  And if so, is
> it dangerous to then kill -9 the process?  What about
> backend cleanups?

Signals are only trapped for if you did not specify the
"-i" command line option -- in other words, only if you
are not running the server from inetd.

Assuming that the above is true, that you are _not_ running
out of inetd, but are instead running it as a standalone
program, then the effect of the signal handler is to set a
global variable "slapd_shutdown" to 1.

Since select() is interrupted by the signal, the return
value will be "-1" with errno set to EINTR.  The code
does not call "siginterrupt(3)" or "sigaction(2)" to set
the system call restart (POSIX signal semantics remain in
effect -- unfortunately, since they make writing a threads
library harder), so we are guarnteed that select will be
interrupted.  This falls to case -1, which calls continue,
which goes to the top of the while() loop, which checks
the value of slapd_shutdown, which exits.

Works great on my FreeBSD 4.x box...

-- Terry Lambert
-- Whistle Communications, Inc., an I.B.M. Company
-- terry@whistle.com
This is formal notice under California Assembly Bill 1629, enacted
9/26/98 that any UCE sent to my email address will be billed $50
per incident to the legally allowed maximum of $25,000.