diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-07-15 22:05:12 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-07-15 22:05:12 -0400 |
commit | 0140dec18019e10c7df9f25dc19cab8e93a430c2 (patch) | |
tree | feb6b6702e3c5570ae9ca5a406dcdda52d0d570c /src/common/wait_error.c | |
parent | 23924feca065aa75f0a9edcf78ad953a51405fe8 (diff) | |
download | postgresql-0140dec18019e10c7df9f25dc19cab8e93a430c2.tar.gz postgresql-0140dec18019e10c7df9f25dc19cab8e93a430c2.zip |
Replace use of sys_siglist[] with strsignal().
This commit back-patches the v12-era commits a73d08319, cc92cca43,
and 7570df0f3 into supported pre-v12 branches. The net effect is to
eliminate our former dependency on the never-standard sys_siglist[]
array, instead using POSIX-standard strsignal(3).
What motivates doing this now is that glibc just removed sys_siglist[]
from the set of symbols available to newly-built programs. While our
code can survive without sys_siglist[], it then fails to print any
description of the signal that killed a child process, which is a
non-negligible loss of friendliness. We can expect that people will
be wanting to build the back branches on platforms that include this
change, so we need to do something.
Since strsignal(3) has existed for quite a long time, and we've not
had any trouble with these patches so far in v12, it seems safe to
back-patch into older branches.
Discussion: https://postgr.es/m/3179114.1594853308@sss.pgh.pa.us
Diffstat (limited to 'src/common/wait_error.c')
-rw-r--r-- | src/common/wait_error.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/common/wait_error.c b/src/common/wait_error.c index 4fb5276961d..cb5df8c89eb 100644 --- a/src/common/wait_error.c +++ b/src/common/wait_error.c @@ -56,25 +56,17 @@ wait_result_to_str(int exitstatus) } } else if (WIFSIGNALED(exitstatus)) + { #if defined(WIN32) snprintf(str, sizeof(str), _("child process was terminated by exception 0x%X"), WTERMSIG(exitstatus)); -#elif defined(HAVE_DECL_SYS_SIGLIST) && HAVE_DECL_SYS_SIGLIST - { - char str2[256]; - - snprintf(str2, sizeof(str2), "%d: %s", WTERMSIG(exitstatus), - WTERMSIG(exitstatus) < NSIG ? - sys_siglist[WTERMSIG(exitstatus)] : "(unknown)"); - snprintf(str, sizeof(str), - _("child process was terminated by signal %s"), str2); - } #else snprintf(str, sizeof(str), - _("child process was terminated by signal %d"), - WTERMSIG(exitstatus)); + _("child process was terminated by signal %d: %s"), + WTERMSIG(exitstatus), pg_strsignal(WTERMSIG(exitstatus))); #endif + } else snprintf(str, sizeof(str), _("child process exited with unrecognized status %d"), |