mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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
This commit is contained in:
@ -650,17 +650,10 @@ pgarch_archiveXlog(char *xlog)
|
||||
errhint("See C include file \"ntstatus.h\" for a description of the hexadecimal value."),
|
||||
errdetail("The failed archive command was: %s",
|
||||
xlogarchcmd)));
|
||||
#elif defined(HAVE_DECL_SYS_SIGLIST) && HAVE_DECL_SYS_SIGLIST
|
||||
ereport(lev,
|
||||
(errmsg("archive command was terminated by signal %d: %s",
|
||||
WTERMSIG(rc),
|
||||
WTERMSIG(rc) < NSIG ? sys_siglist[WTERMSIG(rc)] : "(unknown)"),
|
||||
errdetail("The failed archive command was: %s",
|
||||
xlogarchcmd)));
|
||||
#else
|
||||
ereport(lev,
|
||||
(errmsg("archive command was terminated by signal %d",
|
||||
WTERMSIG(rc)),
|
||||
(errmsg("archive command was terminated by signal %d: %s",
|
||||
WTERMSIG(rc), pg_strsignal(WTERMSIG(rc))),
|
||||
errdetail("The failed archive command was: %s",
|
||||
xlogarchcmd)));
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user