Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15898

"wait" loses signals

From Denys Vlasenko <dvlasenk@redhat.com>
Newsgroups gnu.bash.bug
Subject "wait" loses signals
Date 2020-02-19 11:29 +0100
Message-ID <mailman.1156.1582108234.2412.bug-bash@gnu.org> (permalink)
References <750d460d-b8a4-4157-1488-9f4d9f973715@redhat.com>

Show all headers | View raw


A bug report from Harald van Dijk:

test2.sh:
trap 'kill $!; exit' TERM
{ kill $$; exec sleep 9; } &
wait $!

The above script ought exit quickly, and not leave a stray
"sleep" child:
(1) if "kill $$" signal is delivered before "wait",
then TERM trap will kill the child, and exit.
(2) if "kill $$" signal is delivered to "wait",
it must be interrupted by the signal,
then TERM trap will kill the child, and exit.

The helper to loop the above:

test1.sh:
i=1
while test "$i" -lt 100000; do
      echo "$i"
      "$@" test2.sh
      i=$((i + 1))
done

To run: sh test1.sh <shell_to_test>

bash 4.4.23 fails pretty quickly:

$ sh test1.sh bash
1
...
581
_ <stops here for ~9 seconds>

Under strace, it seems that "wait" enters wait4() syscall
and waits for the child. (The fact that the pause is
9 seconds is another hint).

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

"wait" loses signals Denys Vlasenko <dvlasenk@redhat.com> - 2020-02-19 11:29 +0100

csiph-web