summaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko2020-10-24 03:33:32 +0200
committerDenys Vlasenko2020-10-24 03:33:32 +0200
commitb65d6cb00fa0ea51bac4c4e62b576b43ae2c996b (patch)
treee1d18236b70a031d50f7cdeaf8de501394911e22 /shell/hush.c
parent079487b48724d936b31a6696ae0f929b0251eaa3 (diff)
downloadbusybox-b65d6cb00fa0ea51bac4c4e62b576b43ae2c996b.zip
busybox-b65d6cb00fa0ea51bac4c4e62b576b43ae2c996b.tar.gz
hush: do not print killing signal name in `cmd_whihc_dies_on_signal`
function old new delta process_wait_result 438 449 +11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c
index e9cec1c..2b34b7d 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -8698,9 +8698,15 @@ static int process_wait_result(struct pipe *fg_pipe, pid_t childpid, int status)
*/
if (WIFSIGNALED(status)) {
int sig = WTERMSIG(status);
- if (i == fg_pipe->num_cmds-1)
+ if (G.run_list_level == 1
+ /* ^^^^^ Do not print in nested contexts, example:
+ * echo `sleep 1; sh -c 'kill -9 $$'` - prints "137", NOT "Killed 137"
+ */
+ && i == fg_pipe->num_cmds-1
+ ) {
/* TODO: use strsignal() instead for bash compat? but that's bloat... */
puts(sig == SIGINT || sig == SIGPIPE ? "" : get_signame(sig));
+ }
/* TODO: if (WCOREDUMP(status)) + " (core dumped)"; */
/* TODO: MIPS has 128 sigs (1..128), what if sig==128 here?
* Maybe we need to use sig | 128? */