Skip to content

Commit 95cd890

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 f71b93b commit 95cd890

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
@@ -247,8 +247,16 @@ PgArchiverMain(int argc, char *argv[])
247247
static void
248248
pgarch_exit(SIGNAL_ARGS)
249249
{
250-
/* SIGQUIT means curl up and die ... */
251-
exit(1);
250+
/*
251+
* We DO NOT want to run proc_exit() or atexit() callbacks; they wouldn't
252+
* be safe to run from a signal handler. Just nail the windows shut and
253+
* get out of town.
254+
*
255+
* For consistency with other postmaster children, we do _exit(2) not
256+
* _exit(1). The postmaster currently will treat these exit codes alike,
257+
* but it seems better to report that we died in an unexpected way.
258+
*/
259+
_exit(2);
252260
}
253261

254262
/* SIGHUP signal handler for archiver process */

0 commit comments

Comments
 (0)