diff options
| -rw-r--r-- | mksignal.c | 10 | ||||
| -rw-r--r-- | status.c | 25 |
2 files changed, 16 insertions, 19 deletions
@@ -57,12 +57,9 @@ static struct signaming signamings[] = { #ifdef SIGILL { SIGILL, "sigill", "illegal instruction"}, #endif - -/* We don't want a default message for SIGINT. */ #ifdef SIGINT - { SIGINT, "sigint", ""}, + { SIGINT, "sigint", "interrupt"}, #endif - #ifdef SIGIO { SIGIO, "sigio", "socket i/o possible"}, #endif @@ -78,12 +75,9 @@ static struct signaming signamings[] = { #ifdef SIGLWP { SIGLWP, "siglwp", "thread library signal"}, #endif - -/* By default, SIGPIPEs are silent. */ #ifdef SIGPIPE - { SIGPIPE, "sigpipe", ""}, + { SIGPIPE, "sigpipe", "broken pipe"}, #endif - #ifdef SIGPOLL { SIGPOLL, "sigpoll", "pollable event occurred"}, #endif @@ -64,21 +64,24 @@ extern void setstatus(pid_t pid, int i) { statprint(pid, i); } -/* print a message if termination was with a signal, and if the child dumped core. exit on error if -e is set */ +/* + Print a message if called from the wait builitin in an interactive + shell or termination was with a signal and it is not sigint and + sigpipe or the child dumped core. Exit on error if -e is set. +*/ static void statprint(pid_t pid, int i) { - if (WIFSIGNALED(i)) { - int t = WTERMSIG(i); - char *msg = ((t > 0) && (t < NUMOFSIGNALS) ? signals[WTERMSIG(i)].msg : ""); + int t = WIFSIGNALED(i) ? WTERMSIG(i) : 0; + const char *core = ((t > 0) && myWIFDUMPED(i) ? "--core dumped" : ""); + if ((interactive && pid != -1) || (t > 0 && (*core || (t != SIGINT && t != SIGPIPE)))) { if (pid != -1) fprint(2, "%ld: ", (long)pid); - if (myWIFDUMPED(i)) { - if (*msg == '\0') - fprint(2, "core dumped\n"); - else - fprint(2, "%s--core dumped\n", msg); - } else if (*msg != '\0') - fprint(2, "%s\n", msg); + if (t == 0) + fprint(2, "done (%d)\n", WEXITSTATUS(i)); + else if ((t > 0) && (t < NUMOFSIGNALS) && *signals[t].msg != '\0') + fprint(2, "%s%s\n", signals[t].msg, core); + else + fprint(2, "unknown signal %d%s\n", t, core); } if (i != 0 && dashee && !cond) rc_exit(getstatus()); |