pcp_exit_handler is responsible for waiting for exiting pcp child
process. I suspect it is hung up in the wait loop in regression test
001.
https://www.pgpool.net/pipermail/pgpool-hackers/2023-September/004397.html
So I changed it so that it uses waitpid(2) with WNOHANG option.
pcp_exit_handler(int sig)
{
pid_t wpid;
+ ListCell *lc;
POOL_SETMASK(&AuthBlockSig);
POOL_SETMASK(&UnBlockSig);
- if (list_length(pcp_worker_children) > 0)
+ foreach(lc, pcp_worker_children)
{
+ int pid;
+
do
{
- wpid = wait(NULL);
- } while (wpid > 0 || (wpid == -1 && errno == EINTR));
-
- list_free(pcp_worker_children);
+ wpid = (pid_t) lfirst_int(lc);
+ pid = waitpid(wpid, NULL, WNOHANG);
+ } while (pid == -1 && errno == EINTR);
}
+
pcp_worker_children = NULL;
exit(0);