Centralize logic for restoring errno in signal handlers.
commit28e46325091dfac5c6ab9ea1e047a8d09dbd16e7
authorNathan Bossart <nathan@postgresql.org>
Wed, 14 Feb 2024 22:34:18 +0000 (14 16:34 -0600)
committerNathan Bossart <nathan@postgresql.org>
Wed, 14 Feb 2024 22:34:18 +0000 (14 16:34 -0600)
treef48457af83f13b8bba8d600fe33aef1d39373e26
parent3b00fdba9f20b641d5d3c2b781cd435b23540e61
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
15 files changed:
doc/src/sgml/sources.sgml
src/backend/postmaster/autovacuum.c
src/backend/postmaster/checkpointer.c
src/backend/postmaster/interrupt.c
src/backend/postmaster/pgarch.c
src/backend/postmaster/postmaster.c
src/backend/postmaster/startup.c
src/backend/postmaster/syslogger.c
src/backend/replication/walsender.c
src/backend/storage/ipc/latch.c
src/backend/storage/ipc/procsignal.c
src/backend/tcop/postgres.c
src/backend/utils/misc/timeout.c
src/fe_utils/cancel.c
src/port/pqsignal.c