about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-12-14T14·49+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-12-14T14·49+0000
commitdf303666bceb5715e706478fad0325447a2a52f6 (patch)
tree90b6ae1a414abfde716e26cfdd49da4ae19879f7
parent1e90b4189d5b922479a10eac550736d608b038fd (diff)
* Use strsignal if available to give better error messages for
  builders that fail due to a signal.

-rw-r--r--configure.ac4
-rw-r--r--src/libutil/util.cc12
2 files changed, 14 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 822b15b4b7..581bc4e614 100644
--- a/configure.ac
+++ b/configure.ac
@@ -256,6 +256,10 @@ AM_CONDITIONAL(INIT_STATE, test "$init_state" = "yes")
 AC_CHECK_FUNCS([setresuid setreuid lchown])
 
 
+# Nice to have, but not essential.
+AC_CHECK_FUNCS([strsignal])
+
+
 # This is needed if ATerm, Berkeley DB or bzip2 are static libraries,
 # and the Nix libraries are dynamic.
 if test "$(uname)" = "Darwin"; then
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 37e158e4af..d0731c0b48 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -8,6 +8,7 @@
 #include <cerrno>
 #include <cstdio>
 #include <sstream>
+#include <cstring>
 
 #include <sys/stat.h>
 #include <sys/wait.h>
@@ -960,8 +961,15 @@ string statusToString(int status)
     if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
         if (WIFEXITED(status))
             return (format("failed with exit code %1%") % WEXITSTATUS(status)).str();
-        else if (WIFSIGNALED(status))
-            return (format("failed due to signal %1%") % WTERMSIG(status)).str();
+        else if (WIFSIGNALED(status)) {
+	    int sig = WTERMSIG(status);
+#if HAVE_STRSIGNAL
+            const char * description = strsignal(sig);
+            return (format("failed due to signal %1% (%2%)") % sig % description).str();
+#else
+            return (format("failed due to signal %1%") % sig).str();
+#endif
+	}
         else
             return "died abnormally";
     } else return "succeeded";