From a086144ae2e7f6812bd3c0b66b8f34e1677ec974 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Tue, 12 Oct 2021 10:40:11 +0900 Subject: [PATCH] Fix signal handler for SIGTERM, SIGINT and SIGQUIT. It did not properly save errno and it was possible to overwrite errno. --- src/protocol/child.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/protocol/child.c b/src/protocol/child.c index 687a4e3c1..511ba3bd4 100644 --- a/src/protocol/child.c +++ b/src/protocol/child.c @@ -1077,10 +1077,10 @@ static RETSIGTYPE die(int sig) { int save_errno; - POOL_SETMASK(&BlockSig); - save_errno = errno; + POOL_SETMASK(&BlockSig); + #ifdef NOT_USED ereport(LOG, (errmsg("child process received shutdown request signal %d", sig))); @@ -1125,8 +1125,9 @@ static RETSIGTYPE die(int sig) break; } - errno = save_errno; POOL_SETMASK(&UnBlockSig); + + errno = save_errno; } /* -- 2.39.5