]> diplodocus.org Git - nmh/blobdiff - sbr/pidstatus.c
Reverted commit 9a4b4a3d3b27fe4a7ff6d0b8724ce1c06b5917eb.
[nmh] / sbr / pidstatus.c
index 7da78ace8d664079f10c0c7d67f5d60adfccceab..ded38edc15801a8299a7a5bfce203951430c6b66 100644 (file)
@@ -9,11 +9,6 @@
 
 #include <h/mh.h>
 
-/*
- * auto-generated header
- */
-#include <sigmsg.h>
-
 #ifndef WTERMSIG
 # define WTERMSIG(s) ((int)((s) & 0x7F))
 #endif
 # define WCOREDUMP(s) ((s) & 0x80)
 #endif
 
+/*
+ * Return 0 if the command exited with an exit code of zero, a nonzero code
+ * otherwise.
+ *
+ * Print out an appropriate status message we didn't exit with an exit code
+ * of zero.
+ */
+
 int
 pidstatus (int status, FILE *fp, char *cp)
 {
     int signum;
+    char *signame;
 
 /*
  * I have no idea what this is for (rc)
@@ -42,15 +46,22 @@ pidstatus (int status, FILE *fp, char *cp)
                fprintf (fp, "%s: ", cp);
            fprintf (fp, "exit %d\n", signum);
        }
-    } else if (WIFSIGNALED(status)) {
+       return signum;
+    }
+
+    if (WIFSIGNALED(status)) {
        /* If child process terminated due to receipt of a signal */
        signum = WTERMSIG(status);
        if (signum != SIGINT) {
            if (cp)
                fprintf (fp, "%s: ", cp);
            fprintf (fp, "signal %d", signum);
-           if (signum >= 0 && signum < sizeof(sigmsg) && sigmsg[signum] != NULL)
-               fprintf (fp, " (%s%s)\n", sigmsg[signum],
+           errno = 0;
+           signame = strsignal(signum);
+           if (errno)
+               signame = NULL;
+           if (signame)
+               fprintf (fp, " (%s%s)\n", signame,
                         WCOREDUMP(status) ? ", core dumped" : "");
            else
                fprintf (fp, "%s\n", WCOREDUMP(status) ? " (core dumped)" : "");