From: Noah Misch Date: Thu, 12 Sep 2013 00:10:15 +0000 (-0400) Subject: Ignore interrupts during quickdie(). X-Git-Tag: REL8_4_18~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=312116ed7da6cffb51a4c60a619242b0707cb5dc;p=thirdparty%2Fpostgresql.git Ignore interrupts during quickdie(). Once the administrator has called for an immediate shutdown or a backend crash has triggered a reinitialization, no mere SIGINT or SIGTERM should change that course. Such derailment remains possible when the signal arrives before quickdie() blocks signals. That being a narrow race affecting most PostgreSQL signal handlers in some way, leave it for another patch. Back-patch this to all supported versions. --- diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index b22ea3deb68..382112c727c 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -2488,6 +2488,13 @@ quickdie(SIGNAL_ARGS) { PG_SETMASK(&BlockSig); + /* + * Prevent interrupts while exiting; though we just blocked signals that + * would queue new interrupts, one may have been pending. We don't want a + * quickdie() downgraded to a mere query cancel. + */ + HOLD_INTERRUPTS(); + /* * Ideally this should be ereport(FATAL), but then we'd not get control * back...