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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/28e46325091dfac5c6ab9ea1e047a8d09dbd16e7

Modified Files
--------------
doc/src/sgml/sources.sgml             |  8 --------
src/backend/postmaster/autovacuum.c   |  4 ----
src/backend/postmaster/checkpointer.c |  4 ----
src/backend/postmaster/interrupt.c    |  8 --------
src/backend/postmaster/pgarch.c       |  4 ----
src/backend/postmaster/postmaster.c   | 16 ----------------
src/backend/postmaster/startup.c      | 12 ------------
src/backend/postmaster/syslogger.c    |  4 ----
src/backend/replication/walsender.c   |  4 ----
src/backend/storage/ipc/latch.c       |  4 ----
src/backend/storage/ipc/procsignal.c  |  4 ----
src/backend/tcop/postgres.c           |  8 --------
src/backend/utils/misc/timeout.c      |  4 ----
src/fe_utils/cancel.c                 |  3 ---
src/port/pqsignal.c                   |  6 ++++++
15 files changed, 6 insertions(+), 87 deletions(-)

Reply via email to