aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-08-27 17:24:13 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-08-27 17:24:30 -0400
commit7570df0f3b6d873cd060b3271b5f7b90cbcfb66c (patch)
tree619189b723d89be72337e472eeeac1d5db8d2a4c /src
parentc0222c2c9b8145a0ccbee7d801db848e871f2e14 (diff)
downloadpostgresql-7570df0f3b6d873cd060b3271b5f7b90cbcfb66c.tar.gz
postgresql-7570df0f3b6d873cd060b3271b5f7b90cbcfb66c.zip
Improve what pg_strsignal prints if we haven't got strsignal(3).
Turns out that returning "unrecognized signal" is confusing. Make it explicit that the platform lacks any support for signal names. (At least of the machines in the buildfarm, only HPUX lacks it.) Back-patch to v12 where we invented this function. Discussion: https://postgr.es/m/3067.1566870481@sss.pgh.pa.us
Diffstat (limited to 'src')
-rw-r--r--src/port/pgstrsignal.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/port/pgstrsignal.c b/src/port/pgstrsignal.c
index 146ff0a21ea..93c6ef97ecf 100644
--- a/src/port/pgstrsignal.c
+++ b/src/port/pgstrsignal.c
@@ -32,6 +32,11 @@
*
* This version guarantees to return a non-NULL pointer, although
* some platforms' versions of strsignal() reputedly do not.
+ *
+ * Note that the fallback cases just return constant strings such as
+ * "unrecognized signal". Project style is for callers to print the
+ * numeric signal value along with the result of this function, so
+ * there's no need to work harder than that.
*/
const char *
pg_strsignal(int signum)
@@ -43,8 +48,8 @@ pg_strsignal(int signum)
*/
#ifdef HAVE_STRSIGNAL
result = strsignal(signum);
- if (result)
- return result;
+ if (result == NULL)
+ result = "unrecognized signal";
#else
/*
@@ -52,13 +57,8 @@ pg_strsignal(int signum)
* However, it seems that all platforms with sys_siglist[] have also had
* strsignal() for many years now, so that was just a waste of code.
*/
+ result = "(signal names not available on this platform)";
#endif
- /*
- * Fallback case: just return "unrecognized signal". Project style is for
- * callers to print the numeric signal value along with the result of this
- * function, so there's no need to work harder than this.
- */
- result = "unrecognized signal";
return result;
}