Centralize setup of SIGQUIT handling for postmaster child processes.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Sep 2020 20:04:36 +0000 (16:04 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Sep 2020 20:04:36 +0000 (16:04 -0400)
commit44fc6e259b799f9924de206eeddc1b1fcbcd172f
tree7a3dcb4d2e006b4e1b6ee0597d1420ee0557ab28
parent2000b6c10aa6777929f1a8b613f30426bb90f849
Centralize setup of SIGQUIT handling for postmaster child processes.

We decided that the policy established in commit 7634bd4f6 for
the bgwriter, checkpointer, walwriter, and walreceiver processes,
namely that they should accept SIGQUIT at all times, really ought
to apply uniformly to all postmaster children.  Therefore, get
rid of the duplicative and inconsistent per-process code for
establishing that signal handler and removing SIGQUIT from BlockSig.
Instead, make InitPostmasterChild do it.

The handler set up by InitPostmasterChild is SignalHandlerForCrashExit,
which just summarily does _exit(2).  In interactive backends, we
almost immediately replace that with quickdie, since we would prefer
to try to tell the client that we're dying.  However, this patch is
changing the behavior of autovacuum (both launcher and workers), as
well as walsenders.  Those processes formerly also used quickdie,
but AFAICS that was just mindless copy-and-paste: they don't have
any interactive client that's likely to benefit from being told this.

The stats collector continues to be an outlier, in that it thinks
SIGQUIT means normal exit.  That should probably be changed for
consistency, but there's another patch set where that's being
dealt with, so I didn't do so here.

Discussion: https://postgr.es/m/644875.1599933441@sss.pgh.pa.us
12 files changed:
src/backend/postmaster/autovacuum.c
src/backend/postmaster/bgworker.c
src/backend/postmaster/bgwriter.c
src/backend/postmaster/checkpointer.c
src/backend/postmaster/pgarch.c
src/backend/postmaster/postmaster.c
src/backend/postmaster/startup.c
src/backend/postmaster/walwriter.c
src/backend/replication/walreceiver.c
src/backend/replication/walsender.c
src/backend/tcop/postgres.c
src/backend/utils/init/miscinit.c