From: Igor Maravic Date: Thu, 19 Sep 2013 21:04:00 +0000 (+0200) Subject: pdns: Kill all spawned processes X-Git-Tag: rec-3.6.0-rc1~343^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee443da2d3ca2f831bbc2347088498890417ec13;p=thirdparty%2Fpdns.git pdns: Kill all spawned processes Pipe backend spawned processes can still be alive after the pdns_server-instance was killed. If the children remain alive, sockets will not be released, and the pdns_server-instance can't be respawned. To be sure that all the spawned processes are killed, we must kill by using the process GID. To be able to do the soft reloads, pdns_server-instance is declared as process group lider. Also, all forced kills must kill by GID, not by PID, so all the processes would properly die. Signed-off-by: Igor Maravic Signed-off-by: Alexey Lapitsky --- diff --git a/debian/init.d/pdns b/debian/init.d/pdns index 57e66b8fef..28f6ae0998 100644 --- a/debian/init.d/pdns +++ b/debian/init.d/pdns @@ -68,7 +68,7 @@ case "$1" in force-stop) echo -n "Stopping PowerDNS authoritative nameserver: " - killall -v -9 pdns_server + killall -v -g -9 pdns_server echo "killed" ;; diff --git a/pdns/pdns-recursor.init.d b/pdns/pdns-recursor.init.d index 12348ca174..83e28cd39c 100755 --- a/pdns/pdns-recursor.init.d +++ b/pdns/pdns-recursor.init.d @@ -57,7 +57,7 @@ case "$1" in force-stop) echo -n "Stopping PowerDNS recursing nameserver: " - killall -v -9 pdns_server + killall -v -g -9 pdns_server echo "killed" ;; diff --git a/pdns/receiver.cc b/pdns/receiver.cc index bc514a13ec..331570658a 100644 --- a/pdns/receiver.cc +++ b/pdns/receiver.cc @@ -117,7 +117,7 @@ static void takedown(int i) { if(cpid) { L<&parts, pid_t ppid) { - kill(cpid, SIGKILL); // why? - kill(cpid, SIGKILL); // why? + kill(-getpgid(cpid), SIGKILL); sleep(1); return "ok"; } @@ -220,6 +219,11 @@ static int guardian(int argc, char **argv) signal(SIGUSR1, SIG_DFL); signal(SIGUSR2, SIG_DFL); + // Set different pgrp for this child, + // so we could kill all of it's children + // with one kill call + setpgid(getpid(), 0); + char **const newargv=new char*[argc+2]; int n;