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.
This commit is contained in:
Pádraig Brady 2017-07-23 03:25:32 -07:00
parent 45d1957ce8
commit 900b5621e6
2 changed files with 13 additions and 2 deletions

4
NEWS
View File

@ -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]

View File

@ -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
{