Add errdetail() with PID and UID about source of termination signal.

Andrew Dunstan <andrew@dunslane.net>

Commit: 55890a919454a2165031a04b175ca92e3ed70e69
Author: Andrew Dunstan <andrew@dunslane.net>
Date: 2026-04-07T14:22:33Z
Add errdetail() with PID and UID about source of termination signal.

When a backend is terminated via pg_terminate_backend() or an external
SIGTERM, the error message now includes the sender's PID and UID as
errdetail, making it easier to identify the source of unexpected
terminations in multi-user environments.

On platforms that support SA_SIGINFO (Linux, FreeBSD, and most modern
Unix systems), the signal handler captures si_pid and si_uid from the
siginfo_t structure.  On platforms without SA_SIGINFO, the detail is
simply omitted.

Author: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Chao Li <1356863904@qq.com>
Discussion: https://postgr.es/m/CAKZiRmyrOWovZSdixpLd3PGMQXuQL_zw2Ght5XhHCkQ1uDsxjw@mail.gmail.com

Files

PathChange+/−
configure modified +42 −0
configure.ac modified +18 −0
meson.build modified +4 −0
src/backend/replication/syncrep.c modified +13 −1
src/backend/tcop/postgres.c modified +27 −7
src/backend/utils/init/globals.c modified +2 −0
src/bin/psql/t/001_basic.pl modified +3 −4
src/include/miscadmin.h modified +2 −0
src/include/pg_config.h.in modified +3 −0
src/port/pqsignal.c modified +32 −3

Discussion