Skip to content

Commit 581855b

Browse files
committed
Make archiver's SIGQUIT handler exit via _exit().
Commit 8e19a82 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
1 parent 69fdf3d commit 581855b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/backend/postmaster/pgarch.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,16 @@ PgArchiverMain(int argc, char *argv[])
248248
static void
249249
pgarch_exit(SIGNAL_ARGS)
250250
{
251-
/* SIGQUIT means curl up and die ... */
252-
exit(1);
251+
/*
252+
* We DO NOT want to run proc_exit() or atexit() callbacks; they wouldn't
253+
* be safe to run from a signal handler. Just nail the windows shut and
254+
* get out of town.
255+
*
256+
* For consistency with other postmaster children, we do _exit(2) not
257+
* _exit(1). The postmaster currently will treat these exit codes alike,
258+
* but it seems better to report that we died in an unexpected way.
259+
*/
260+
_exit(2);
253261
}
254262

255263
/* SIGHUP signal handler for archiver process */

0 commit comments

Comments
 (0)