I tried to do this script:
#!/bin/bash
trap "echo trapped!" SIGUSR2
sleep 3s
kill -SIGUSR2 $$;
exit 0
and it works because it kills itself "from the inner". if i try this
#!/bin/bash
trap "echo trapped!" SIGUSR2
echo "PID: $$";
while true
do
sleep 1m
done
exit 0
and from another terminal i try to kill the script it seems don't accept the signal and so it does nothing. Why?