From: Pádraig Brady
Date: Sun, 23 Jul 2017 10:25:32 +0000 (-0700) Subject: kill: fix signal number to name lookup on AIX X-Git-Tag: v8.28~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=900b5621e685df7ffd001fc64bc9d44b06b13900;p=thirdparty%2Fcoreutils.git kill: fix signal number to name lookup on AIX * src/operand2sig.c (operand2sig): AIX uses a different bit pattern in the returned status from the wait() functions and from shells. Therefore hardcode the selection of the lower bits of the number. * NEWS: Mention the fix. --- diff --git a/NEWS b/NEWS index eb0c0dcb30..6b6cafdae9 100644 --- a/NEWS +++ b/NEWS @@ -41,6 +41,10 @@ GNU coreutils NEWS -*- outline -*- Now, it prints a diagnostic or a line to stdout for each argument. [bug introduced in the bourne-shell-to-C rewrite for coreutils-6.11] + kill now converts from number to signal name correctly on AIX. + Previously it would have always returned the 'EXIT' name. + [bug introduced in fileutils-4.1.9] + split no longer exits when invocations of a --filter return EPIPE. [bug introduced in coreutils-8.26] diff --git a/src/operand2sig.c b/src/operand2sig.c index d59ccb9279..db5ceea29d 100644 --- a/src/operand2sig.c +++ b/src/operand2sig.c @@ -53,8 +53,15 @@ operand2sig (char const *operand, char *signame) char *endp; long int l = (errno = 0, strtol (operand, &endp, 10)); int i = l; - signum = (operand == endp || *endp || errno || i != l ? -1 - : WIFSIGNALED (i) ? WTERMSIG (i) : i); + signum = (operand == endp || *endp || errno || i != l ? -1 : i); + + if (signum != -1) + { + /* Note AIX uses a different bit pattern for status returned + from shell and wait(), so we can't use WTERMSIG etc. here. + Also ksh returns 0xFF + signal number. */ + signum &= signum >= 0xFF ? 0xFF : 0x7F; + } } else {