[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"wait" loses signals

From: Denys Vlasenko
Subject: "wait" loses signals
Date: Wed, 19 Feb 2020 11:29:02 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

A bug report from Harald van Dijk:

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:

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

To run: sh test1.sh <shell_to_test>

bash 4.4.23 fails pretty quickly:

$ sh test1.sh bash
_ <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).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]