summaryrefslogtreecommitdiff
path: root/src/fe_utils
diff options
context:
space:
mode:
authorNathan Bossart2024-02-14 22:34:18 +0000
committerNathan Bossart2024-02-14 22:34:18 +0000
commit28e46325091dfac5c6ab9ea1e047a8d09dbd16e7 (patch)
treef48457af83f13b8bba8d600fe33aef1d39373e26 /src/fe_utils
parent3b00fdba9f20b641d5d3c2b781cd435b23540e61 (diff)
Centralize logic for restoring errno in signal handlers.
Presently, we rely on each individual signal handler to save the initial value of errno and then restore it before returning if needed. This is easily forgotten and, if missed, often goes undetected for a long time. In commit 3b00fdba9f, we introduced a wrapper signal handler function that checks whether MyProcPid matches getpid(). This commit moves the aforementioned errno restoration code from the individual signal handlers to the new wrapper handler so that we no longer need to worry about missing it. Reviewed-by: Andres Freund, Noah Misch Discussion: https://postgr.es/m/20231121212008.GA3742740%40nathanxps13
Diffstat (limited to 'src/fe_utils')
-rw-r--r--src/fe_utils/cancel.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/src/fe_utils/cancel.c b/src/fe_utils/cancel.c
index 12f005818d6..dcff9a85641 100644
--- a/src/fe_utils/cancel.c
+++ b/src/fe_utils/cancel.c
@@ -152,7 +152,6 @@ ResetCancelConn(void)
static void
handle_sigint(SIGNAL_ARGS)
{
- int save_errno = errno;
char errbuf[256];
CancelRequested = true;
@@ -173,8 +172,6 @@ handle_sigint(SIGNAL_ARGS)
write_stderr(errbuf);
}
}
-
- errno = save_errno; /* just in case the write changed it */
}
/*