Merge pull request #1868 from kadler/fix-aix-signal-checking

Handle process signalling correctly on AIX
diff --git a/src/subprocess-posix.cc b/src/subprocess-posix.cc
index 0c5f556..8e78540 100644
--- a/src/subprocess-posix.cc
+++ b/src/subprocess-posix.cc
@@ -154,6 +154,16 @@
     Fatal("waitpid(%d): %s", pid_, strerror(errno));
   pid_ = -1;
 
+#ifdef _AIX
+  if (WIFEXITED(status) && WEXITSTATUS(status) & 0x80) {
+    // Map the shell's exit code used for signal failure (128 + signal) to the
+    // status code expected by AIX WIFSIGNALED and WTERMSIG macros which, unlike
+    // other systems, uses a different bit layout.
+    int signal = WEXITSTATUS(status) & 0x7f;
+    status = (signal << 16) | signal;
+  }
+#endif
+
   if (WIFEXITED(status)) {
     int exit = WEXITSTATUS(status);
     if (exit == 0)