From 474ef55cb93a426d15cbd24666525349d9f9f5f4 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Wed, 18 Mar 2009 19:27:30 +0000 Subject: [PATCH] Don't intercept SIGQUIT as a signal to trigger failover; that's what postmaster uses for immediate shutdown. Trap SIGUSR1 as the preferred signal for that. Per report by Fujii Masao and subsequent discussion on -hackers. --- contrib/pg_standby/pg_standby.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/contrib/pg_standby/pg_standby.c b/contrib/pg_standby/pg_standby.c index 66b4dc4502c..8b95682c753 100644 --- a/contrib/pg_standby/pg_standby.c +++ b/contrib/pg_standby/pg_standby.c @@ -451,14 +451,36 @@ sighandler(int sig) signaled = true; } +/* We don't want SIGQUIT to core dump */ +static void +sigquit_handler(int sig) +{ + signal(SIGINT, SIG_DFL); + kill(getpid(), SIGINT); +} + + /*------------ MAIN ----------------------------------------*/ int main(int argc, char **argv) { int c; - (void) signal(SIGINT, sighandler); - (void) signal(SIGQUIT, sighandler); + /* + * You can send SIGUSR1 to trigger failover. + * + * Postmaster uses SIGQUIT to request immediate shutdown. The default + * action is to core dump, but we don't want that, so trap it and + * commit suicide without core dump. + * + * We used to use SIGINT and SIGQUIT to trigger failover, but that + * turned out to be a bad idea because postmaster uses SIGQUIT to + * request immediate shutdown. We still trap SIGINT, but that may + * change in a future release. + */ + (void) signal(SIGUSR1, sighandler); + (void) signal(SIGINT, sighandler); /* deprecated, use SIGUSR1 */ + (void) signal(SIGQUIT, sigquit_handler); while ((c = getopt(argc, argv, "cdk:lr:s:t:w:")) != -1) { -- 2.39.5