>From 35eb8c25f59c6bd81949a4daf4339f1eac30d15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sun, 23 Jul 2017 03:25:32 -0700 Subject: [PATCH] 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 provided number when on AIX. * NEWS: Mention the fix. --- NEWS | 4 ++++ src/operand2sig.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index dfd2837..22bef54 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,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] + shred now erases buffers containing secrets via the explicit_bzero function, which should be more reliable. [potential bug has always been present in 'shred'] diff --git a/src/operand2sig.c b/src/operand2sig.c index d59ccb9..3b57b21 100644 --- a/src/operand2sig.c +++ b/src/operand2sig.c @@ -53,8 +53,18 @@ 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) + { +#ifdef _AIX + /* AIX uses a different bit pattern for status returned + from shell and wait(), therefore just consider the lower bits. */ + signum &= signum >= 0xFF ? 0xFF : 0x7F; +#else + signum = WIFSIGNALED (signum) ? WTERMSIG (signum) : signum; +#endif + } } else { -- 2.9.3