X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/4bc573a0c6adf03ac7154f99f479a30b56012ab9..d3e11c5e9:/sbr/pidstatus.c?ds=sidebyside diff --git a/sbr/pidstatus.c b/sbr/pidstatus.c index 1c1f7348..6e4c2c7d 100644 --- a/sbr/pidstatus.c +++ b/sbr/pidstatus.c @@ -1,6 +1,4 @@ - -/* - * pidstatus.c -- report child's status +/* pidstatus.c -- report child's status * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -9,11 +7,6 @@ #include -/* - * auto-generated header - */ -#include - #ifndef WTERMSIG # define WTERMSIG(s) ((int)((s) & 0x7F)) #endif @@ -34,6 +27,7 @@ int pidstatus (int status, FILE *fp, char *cp) { int signum; + char *signame; /* * I have no idea what this is for (rc) @@ -51,16 +45,21 @@ pidstatus (int status, FILE *fp, char *cp) fprintf (fp, "exit %d\n", signum); } return signum; - } else if (WIFSIGNALED(status)) { + } + + 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 < (int) 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)" : "");