Skip to content

Commit

Permalink
tests/wait-p: Don't depend on yash-specific behavior
Browse files Browse the repository at this point in the history
Previously, the test case 'trap interrupts wait' assumed that the
asynchronous subshell ran as a direct child process of the main shell.
This assumption was not POSIXly-portable. The shell is allowed to run
the subshell in a child process of the asynchronous job's process, in
which case the job process might be terminated by SIGUSR2 before the
trap action is performed in the subshell.

This commit rewrites the test so that the test result does not depend on
the wait status for the subshell.
  • Loading branch information
magicant committed Feb 1, 2024
1 parent d8c9e8b commit 6408b96
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tests/wait-p.tst
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,19 @@ __IN__
test_oE 'trap interrupts wait' -m
interrupted=false
trap 'interrupted=true' USR1
(
set +m
trap 'echo received USR2; exit' USR2
while kill -s USR1 $$; do sleep 1; done # loop until signaled
)&
wait $!
while kill -s 0 $$; do kill -s USR1 $$; done&
# The asynchronous job should eventually interrupt the wait.
wait
status=$?
echo interrupted=$interrupted $((status > 128))
kill -l $status
# Now, the background job should be still running.
# Now the job should be still running. Kill it.
kill -s USR2 %
wait $!
wait
echo waited $?
__IN__
interrupted=true 1
USR1
received USR2
waited 0
__OUT__

Expand Down

0 comments on commit 6408b96

Please sign in to comment.