Occurs at least on GNU bash version 4.3.42 x86_64 && GNU bash version 4.3.11 x86_64
I use sleep & wait $! instead of a simple sleep for getting an interruptible sleep by a signal (as SIGUSR1).
But it seems that the wait bash-builtin behaves in a strange way when you run the following.
Terminal 1:
cat <(
trap 'echo SIGUSR1' SIGUSR1;
echo $BASHPID;
while :;do
sleep 1 &
wait $!;
echo test;
done
)&
Terminal 2:
kill -10 /the pid of the subshell, printed by the previous command/
Terminal 1:
^C (ctrl + C)
Then, I get the subshell that burns a CPU at 100 percent.
Terminal 1:
pkill -P $(pgrep -P $$)
Do you have any idea about why this behavior occurs?
NB: no problem occurs when the cat <(/subshell/) isn't in the background.
Another way to experience this behavior
Terminal 1:
(
trap 'echo SIGUSR1' SIGUSR1;
echo $BASHPID;
while :;do
sleep 1 &
wait $!;
echo test;
done
)&
Terminal 2:
kill -10 /the pid of the subshell, printed by the previous command/
Terminal 1:
fg
^C (ctrl + C)
Then, get a frozen shell.
A third way to experience this behavior
Terminal 1:
(
trap 'echo SIGUSR1' SIGUSR1;
echo $BASHPID;
while :;do
sleep 1 &
wait $!;
echo test;
done
)
Terminal 2:
kill -10 /the pid of the subshell, printed by the previous command/
Terminal 1:
^C (ctrl + C)
Then, get a frozen shell.