There's a race condition when you can hit following:
set_signal_handler (sig, SIG_IGN);
change_signal (sig, savestring (string));
set_signal_handler (sig, trap_handler);
in trap.c file, set_signal() function.
So bash set signal to be ignored and then set it to be handled by
trap_handler. However how should bash behave when the signal is received
when the trap_handler has been set before. Check the following reproducer:
#!/bin/bash
cat> traploop.sh<<EOF
while true; do
trap exit SIGUSR1;
done
EOF
chmod a+x traploop.sh
i=0
while true; do
./traploop.sh&
sleep 1
echo "Sending SIGUSR1 to $!"
kill -SIGUSR1 $!
wait $!
echo "No. $i: OK"
i=$((i+1))
done
You can send SIGUSR1 to bash running traploop.sh in the state, when the
signal is ignored, but shouldn't be. Is there any reason why is the
signal for short time ignored?
RR