]> mj.ucw.cz Git - libucw.git/commitdiff
Process: Let format_exit_status() name the lethal signal
authorMartin Mares <mj@ucw.cz>
Wed, 18 Jul 2012 10:14:53 +0000 (12:14 +0200)
committerMartin Mares <mj@ucw.cz>
Wed, 18 Jul 2012 10:14:53 +0000 (12:14 +0200)
ucw/exitstatus.c
ucw/process.h

index fec5593f1ee8a45720bbdba6f9bb1c3570ad07a2..7ce1ff5ac7ec17023a3912aa933ff8adea6f9cd0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     UCW Library -- Formatting of Process Exit Status
  *
- *     (c) 2004 Martin Mares <mj@ucw.cz>
+ *     (c) 2004--2012 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
@@ -9,6 +9,7 @@
 
 #include <ucw/lib.h>
 #include <ucw/process.h>
+#include <ucw/signames.h>
 
 #include <stdio.h>
 #include <sys/wait.h>
@@ -30,7 +31,11 @@ format_exit_status(char *msg, int stat)
        }
     }
   else if (WIFSIGNALED(stat))
-    sprintf(msg, "died on signal %d", WTERMSIG(stat));
+    {
+      int sig = WTERMSIG(stat);
+      const char *sn = sig_number_to_name(sig);
+      sprintf(msg, "died on signal %d (%s)", sig, (sn ? : "unknown"));
+    }
   else
     sprintf(msg, "died with status %x", stat);
   return 1;
index 1bbeedac3f07bb5379515683024cb986cb90e221..2c7802379c6b5eec525fd950e34ff27253b3cf16 100644 (file)
@@ -18,7 +18,7 @@ char *getproctitle(void);
 
 /* exitstatus.c */
 
-#define EXIT_STATUS_MSG_SIZE 32
+#define EXIT_STATUS_MSG_SIZE 64
 int format_exit_status(char *msg, int stat);
 
 /* runcmd.c */