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.
{
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)
{
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)