I have a script whose internals boil down to:
trap "exit" SIGINT SIGTERM
while :
do
mplayer sound.mp3
sleep 3
done
(yes, it is a bit more meaningful than the above, but that's not relevant to the problem). Several instances of the script may be running at the same time.
Sometimes I want to ^C the script... but that does not succeed. As I understand, when ^C kills mplayer
, it continues to sleep
, and when ^C kills sleep
, it continues to mplayer
, and I never happen to catch it in between. As I understand, trap
just never works.
How do I terminate the script?