aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-01-20 12:57:17 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2020-01-20 12:57:17 -0500
commitb1392a9502016fcd3c93ba18ab418e11424b711e (patch)
tree7005288ec2f63421ff6d76434a9f8e37d259299b
parent98f0d283774b68895bc41413d7dd9c19e5608231 (diff)
downloadpostgresql-b1392a9502016fcd3c93ba18ab418e11424b711e.tar.gz
postgresql-b1392a9502016fcd3c93ba18ab418e11424b711e.zip
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
-rw-r--r--src/bin/pg_dump/parallel.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
index ce3a06ae816..de776a91891 100644
--- a/src/bin/pg_dump/parallel.c
+++ b/src/bin/pg_dump/parallel.c
@@ -573,8 +573,11 @@ sigTermHandler(SIGNAL_ARGS)
write_stderr("terminated by user\n");
}
- /* And die. */
- exit(1);
+ /*
+ * And die, using _exit() not exit() because the latter will invoke atexit
+ * handlers that can fail if we interrupted related code.
+ */
+ _exit(1);
}
/*