Enhance SIGHLD handler of Pgpool-II main process.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 24 Oct 2021 07:22:33 +0000 (16:22 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 24 Oct 2021 07:37:24 +0000 (16:37 +0900)
When Pgpool-II child is killed by SIGKILL signal, the SIGHLD handler
just emitted LOG level message as other signals.  But SIGKILL is an
important event, for example killed by OOM killer. So emit a WARNING
level message instead.

Per suggestion from Michail Alexakis.
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2021-October/007808.html

src/main/pgpool_main.c

index c06ffa08ad6c60877165c0e36143cad4055917ed..c92b93ea67d8657c9a160ac291db37c8d7a82ec6 100644 (file)
@@ -2509,10 +2509,13 @@ static void reaper(void)
                }
                if (WIFSIGNALED(status))
                {
-                       /* Child terminated by segmentation fault. Report it */
-                       if(WTERMSIG(status) == SIGSEGV)
+                       /* Child terminated by segmentation fault or sigkill. Report it */
+                       if (WTERMSIG(status) == SIGSEGV)
                                ereport(WARNING,
-                                       (errmsg("%s process with pid: %d was terminated by segmentation fault", exiting_process_name,pid)));
+                                               (errmsg("%s process with pid: %d was terminated by segmentation fault", exiting_process_name, pid)));
+                       else if (WTERMSIG(status) == SIGKILL)
+                               ereport(WARNING,
+                                               (errmsg("%s process with pid: %d was terminated by sigkill", exiting_process_name, pid)));
                        else
                                ereport(LOG,
                                                (errmsg("%s process with pid: %d exits with status %d by signal %d", exiting_process_name, pid, status, WTERMSIG(status))));