Skip to content

Commit 6f6daa1

Browse files
committed
Fix pg_dump's sigTermHandler() to use _exit() not exit().
sigTermHandler() tried to be careful to invoke only operations that are safe to do in a signal handler. But for some reason we forgot that exit(3) is not among those, because it calls atexit handlers that might do various random things. (pg_dump itself installs no atexit handlers, but e.g. OpenSSL does.) That led to crashes or lockups when attempting to terminate a parallel dump or restore via a signal. Fix by calling _exit() instead. Per bug #16199 from Raúl Marín. Back-patch to all supported branches. Discussion: https://postgr.es/m/16199-cb2f121146a96f9b@postgresql.org
1 parent ff0c567 commit 6f6daa1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/bin/pg_dump/parallel.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,11 @@ sigTermHandler(SIGNAL_ARGS)
609609
write_stderr("terminated by user\n");
610610
}
611611

612-
/* And die. */
613-
exit(1);
612+
/*
613+
* And die, using _exit() not exit() because the latter will invoke atexit
614+
* handlers that can fail if we interrupted related code.
615+
*/
616+
_exit(1);
614617
}
615618

616619
/*

0 commit comments

Comments
 (0)