diff options
author | Tom Lane | 2020-01-20 17:57:17 +0000 |
---|---|---|
committer | Tom Lane | 2020-01-20 17:57:17 +0000 |
commit | cd23a2019c4b8da47905e91c8a841cadac978a32 (patch) | |
tree | 7152e8156e99380890166dbc752766042471cbdb /src | |
parent | 4c87010981f3a9a41751e5550f6eb889ab5667e8 (diff) |
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/[email protected]
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_dump/parallel.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c index 8582b65524c..1410bcdb662 100644 --- a/src/bin/pg_dump/parallel.c +++ b/src/bin/pg_dump/parallel.c @@ -606,8 +606,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); } /* |