From e6d960686cd1cdeb03594a3785259c0cf5c2a016 Mon Sep 17 00:00:00 2001 From: Muhammad Usama Date: Wed, 4 Jan 2017 18:23:33 +0500 Subject: [PATCH] Fix for 0000249: watchdog sometimes fails de-escalation. The logic in pgpool-II main process exit_handler and terminate_all_childrens was not making sure that pgpool-II main process should only exit after all its children have exited. And the problem occurs when the main process shutdowns itself before watchdog and de-escalation child processes. The solution is to use the waitpid() system call without WNOHANG option. --- src/main/pgpool_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c index 56d58d053..f633bba5e 100644 --- a/src/main/pgpool_main.c +++ b/src/main/pgpool_main.c @@ -1076,7 +1076,7 @@ static void terminate_all_childrens() { int ret_pid; - wpid = waitpid(-1, &ret_pid, WNOHANG); + wpid = waitpid(-1, &ret_pid, 0); } while (wpid > 0 || (wpid == -1 && errno == EINTR)); if (wpid == -1 && errno != ECHILD) @@ -1449,7 +1449,7 @@ static RETSIGTYPE exit_handler(int sig) { int ret_pid; - wpid = waitpid(-1, &ret_pid, WNOHANG); + wpid = waitpid(-1, &ret_pid, 0); } while (wpid > 0 || (wpid == -1 && errno == EINTR)); if (wpid == -1 && errno != ECHILD) -- 2.39.5