Skip to content

Commit d038c6c

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 ef1e125 commit d038c6c

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
@@ -255,8 +255,16 @@ PgArchiverMain(int argc, char *argv[])
255255
static void
256256
pgarch_exit(SIGNAL_ARGS)
257257
{
258-
/* SIGQUIT means curl up and die ... */
259-
exit(1);
258+
/*
259+
* We DO NOT want to run proc_exit() or atexit() callbacks; they wouldn't
260+
* be safe to run from a signal handler. Just nail the windows shut and
261+
* get out of town.
262+
*
263+
* For consistency with other postmaster children, we do _exit(2) not
264+
* _exit(1). The postmaster currently will treat these exit codes alike,
265+
* but it seems better to report that we died in an unexpected way.
266+
*/
267+
_exit(2);
260268
}
261269

262270
/* SIGHUP signal handler for archiver process */

0 commit comments

Comments
 (0)