pgsql: Modernize our code for looking up descriptive strings for Unix s

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Modernize our code for looking up descriptive strings for Unix s
Date: 2018-12-17 00:39:07
Message-ID: E1gYgw7-0005e1-Hm@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Modernize our code for looking up descriptive strings for Unix signals.

At least as far back as the 2008 spec, POSIX has defined strsignal(3)
for looking up descriptive strings for signal numbers. We hadn't gotten
the word though, and were still using the crufty old sys_siglist array,
which is in no standard even though most Unixen provide it.

Aside from not being formally standards-compliant, this was just plain
ugly because it involved #ifdef's at every place using the code.

To eliminate the #ifdef's, create a portability function pg_strsignal,
which wraps strsignal(3) if available and otherwise falls back to
sys_siglist[] if available. The set of Unixen with neither API is
probably empty these days, but on any platform with neither, you'll
just get "unrecognized signal". All extant callers print the numeric
signal number too, so no need to work harder than that.

Along the way, upgrade pg_basebackup's child-error-exit reporting
to match the rest of the system.

Discussion: https://postgr.es/m/25758.1544983503@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a73d08319537d807a520a72bc5bd17279672c3de

Modified Files
--------------
configure | 2 +-
configure.in | 1 +
src/backend/postmaster/pgarch.c | 11 ++----
src/backend/postmaster/postmaster.c | 16 +++------
src/bin/pg_basebackup/pg_basebackup.c | 18 ++++------
src/common/wait_error.c | 16 +++------
src/include/pg_config.h.in | 3 ++
src/include/pg_config.h.win32 | 3 ++
src/include/port.h | 3 ++
src/port/Makefile | 2 +-
src/port/pgstrsignal.c | 67 +++++++++++++++++++++++++++++++++++
src/test/regress/pg_regress.c | 9 ++---
12 files changed, 97 insertions(+), 54 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2018-12-17 01:38:09 pgsql: Make constraint rename issue relcache invalidation on target rel
Previous Message Tom Lane 2018-12-16 19:52:06 pgsql: Make error handling in parallel pg_upgrade less bogus.