diff options
author | tjr <tjr@FreeBSD.org> | 2002-07-18 09:37:51 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-07-18 09:37:51 +0000 |
commit | 60af0dcffab9e488729039c35d7ebff3a5b7533d (patch) | |
tree | a2bb8be00a86a9eaad369c063077e004b3f21ec7 /bin/sh | |
parent | 0b1947f6a938622c0ffbaaba02e0c72b0c04551c (diff) | |
download | FreeBSD-src-60af0dcffab9e488729039c35d7ebff3a5b7533d.zip FreeBSD-src-60af0dcffab9e488729039c35d7ebff3a5b7533d.tar.gz |
Make the message that is printed when the foreground process is terminated
by a signal the same as pdksh/bash/sh before rev. 1.34.
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/jobs.c | 25 | ||||
-rw-r--r-- | bin/sh/jobs.h | 1 |
2 files changed, 24 insertions, 2 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index a8cf28d..0a76e9b 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -208,6 +208,7 @@ fgcmd(int argc __unused, char **argv) pgrp = jp->ps[0].pid; tcsetpgrp(ttyfd, pgrp); restartjob(jp); + jp->foreground = 1; INTOFF; status = waitforjob(jp, (int *)NULL); INTON; @@ -228,6 +229,7 @@ bgcmd(int argc, char **argv) if (jp->state == JOBDONE) continue; restartjob(jp); + jp->foreground = 0; fmtstr(s, 64, "[%d] ", jp - jobtab + 1); out1str(s); out1str(jp->ps[0].cmd); @@ -633,6 +635,7 @@ makejob(union node *node __unused, int nprocs) jp->used = 1; jp->changed = 0; jp->nprocs = 0; + jp->foreground = 0; #if JOBS jp->jobctl = jobctl; jp->next = NULL; @@ -813,6 +816,7 @@ forkshell(struct job *jp, union node *n, int mode) ps->cmd = nullstr; if (iflag && rootshell && n) ps->cmd = commandtext(n); + jp->foreground = mode == FORK_FG; #if JOBS setcurjob(jp); #endif @@ -906,6 +910,7 @@ dowait(int block, struct job *job) int done; int stopped; int sig; + int i; in_dowait++; TRACE(("dowait(%d) called\n", block)); @@ -967,8 +972,24 @@ dowait(int block, struct job *job) else sig = WTERMSIG(status); } - if (sig != 0 && sig != SIGINT && sig != SIGPIPE) - showjob(thisjob, pid, 0, 1); + if (sig != 0 && sig != SIGINT && sig != SIGPIPE) { + if (jp->foreground) { +#if JOBS + if (WIFSTOPPED(status)) + i = WSTOPSIG(status); + else +#endif + i = WTERMSIG(status); + if ((i & 0x7F) < NSIG && sys_siglist[i & 0x7F]) + out1str(sys_siglist[i & 0x7F]); + else + out1fmt("Signal %d", i & 0x7F); + if (WCOREDUMP(status)) + out1str(" (core dumped)"); + out1c('\n'); + } else + showjob(thisjob, pid, 0, 1); + } } else { TRACE(("Not printing status, rootshell=%d, job=0x%x\n", rootshell, job)); if (thisjob) diff --git a/bin/sh/jobs.h b/bin/sh/jobs.h index ad0a74f..5bc32eb 100644 --- a/bin/sh/jobs.h +++ b/bin/sh/jobs.h @@ -71,6 +71,7 @@ struct job { char state; /* true if job is finished */ char used; /* true if this entry is in used */ char changed; /* true if status has changed */ + char foreground; /* true if running in the foreground */ #if JOBS char jobctl; /* job running under job control */ struct job *next; /* job used after this one */ |