summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-10-24 03:33:32 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-01-01 14:30:58 +0100
commit0f668aad7ff7ee55141c93498636921b4a52f2eb (patch)
tree7eb1dc2bc148f63b6fe7bb6afe0b8616ef119dee
parent06f7cf148767a0b521bd296c276df5169add5cfb (diff)
downloadbusybox-0f668aad7ff7ee55141c93498636921b4a52f2eb.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>
-rw-r--r--shell/hush.c8
-rw-r--r--shell/hush_test/hush-psubst/tick6.right1
-rwxr-xr-xshell/hush_test/hush-psubst/tick6.tests1
3 files changed, 9 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c
index e9cec1cc9..2b34b7da5 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? */
diff --git a/shell/hush_test/hush-psubst/tick6.right b/shell/hush_test/hush-psubst/tick6.right
new file mode 100644
index 000000000..065fd3e79
--- /dev/null
+++ b/shell/hush_test/hush-psubst/tick6.right
@@ -0,0 +1 @@
+137
diff --git a/shell/hush_test/hush-psubst/tick6.tests b/shell/hush_test/hush-psubst/tick6.tests
new file mode 100755
index 000000000..33dd3630d
--- /dev/null
+++ b/shell/hush_test/hush-psubst/tick6.tests
@@ -0,0 +1 @@
+true; echo `sh -c 'kill -9 $$'` $?