From d8c9e8b54d79f4e6a3a2e2b907d0d64c6785cb3c Mon Sep 17 00:00:00 2001 From: WATANABE Yuki Date: Thu, 1 Feb 2024 00:52:36 +0900 Subject: [PATCH] tests/kill4: Fix tests with wrong assumption Previously, some tests in kill4-p.tst depended on traps reacting to a signal sent by the shell. Since the traps were set in subshells, the processes executing the trap built-in might not be the direct child processes of the shell. In that case, the children were terminated by the signal, possibly before the subshells responded to the signal, causing the subsequent wait built-in to return too early in the main shell process. To resolve this issue, the test cases are rewritten without using traps. --- tests/kill4-p.tst | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/kill4-p.tst b/tests/kill4-p.tst index afcbb891..0e45c394 100644 --- a/tests/kill4-p.tst +++ b/tests/kill4-p.tst @@ -42,32 +42,34 @@ setup 'halt() while kill -s CONT $$; do sleep 1; done' mkfifo fifo1 fifo2 fifo3 test_oE 'sending signal to background job' -m -(trap 'echo 1; exit' USR1; >fifo1; halt) | -(trap 'echo 2; cat; exit' USR1; >fifo2; halt) | -(trap 'echo 3; cat; exit' USR1; >fifo3; halt) & +# The subshells stop at the redirections, waiting for the unopened FIFOs. +(>fifo1; echo not reached 1 >&2) | +(>fifo2; echo not reached 2 >&2) | +(>fifo3; echo not reached 3 >&2) & halt & -fifo1; halt X) & -(trap 'echo; exit' TERM; >fifo2; halt Y) & -fifo1; echo not reached 1 >&2) & +(>fifo2; echo not reached 2 >&2) & +kill '%?fifo1' '%?fifo2' +wait '%?fifo1' +kill -l $? +wait '%?fifo2' +kill -l $? __IN__ - - +TERM +TERM __OUT__ )