aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-09-09 15:32:34 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-09-09 15:32:34 -0400
commit581855b6ae2309131ab9301f5155294b770ff8b1 (patch)
tree6e1dc1987aa9c492c01b68e565432bf6ac9409f9
parent69fdf3d2e987cb5543f00a945cffbf6e422d5868 (diff)
downloadpostgresql-581855b6ae2309131ab9301f5155294b770ff8b1.tar.gz
postgresql-581855b6ae2309131ab9301f5155294b770ff8b1.zip
Make archiver's SIGQUIT handler exit via _exit().
Commit 8e19a8264 changed the SIGQUIT handlers of almost all server processes not to run atexit callbacks. The archiver process was skipped, perhaps because it's not connected to shared memory; but it's just as true here that running atexit callbacks in a signal handler is unsafe. So let's make it work like the rest. In HEAD and v13, we can use the common SignalHandlerForCrashExit handler. Before that, just tweak pgarch_exit to use _exit(2) explicitly. Like the previous commit, back-patch to all supported branches. Kyotaro Horiguchi, back-patching by me Discussion: https://postgr.es/m/1850884.1599601164@sss.pgh.pa.us
-rw-r--r--src/backend/postmaster/pgarch.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index 9691649ac7d..8053a27b1a1 100644
--- a/src/backend/postmaster/pgarch.c
+++ b/src/backend/postmaster/pgarch.c
@@ -248,8 +248,16 @@ PgArchiverMain(int argc, char *argv[])
static void
pgarch_exit(SIGNAL_ARGS)
{
- /* SIGQUIT means curl up and die ... */
- exit(1);
+ /*
+ * We DO NOT want to run proc_exit() or atexit() callbacks; they wouldn't
+ * be safe to run from a signal handler. Just nail the windows shut and
+ * get out of town.
+ *
+ * For consistency with other postmaster children, we do _exit(2) not
+ * _exit(1). The postmaster currently will treat these exit codes alike,
+ * but it seems better to report that we died in an unexpected way.
+ */
+ _exit(2);
}
/* SIGHUP signal handler for archiver process */