]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
kill: fix signal number to name lookup on AIX
authorPádraig Brady <P@draigBrady.com>
Sun, 23 Jul 2017 10:25:32 +0000 (03:25 -0700)
committerPádraig Brady <P@draigBrady.com>
Mon, 14 Aug 2017 04:33:01 +0000 (21:33 -0700)
* 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.

NEWS
src/operand2sig.c

diff --git a/NEWS b/NEWS
index eb0c0dcb3089b3c0d0eccc280f57cae9bd75282a..6b6cafdae98ff4c73e07129f7d8f522b34b811eb 100644 (file)
--- 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]
 
index d59ccb927902a5590ae9c80f5285de680df7a13e..db5ceea29d4fc98126c6ae690fda5db459bdb853 100644 (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
     {