I have a following bash script:
#!/bin/bash
for i in {0..8}
do
trap "echo received $i" $i
done
trap "echo 'receiving the SIGINT'; kill -9 $$" INT
for i in {10..64}
do
trap "echo receiving the $i" $i
done
sleep 1h
If run it and from other terminal send the SIGINT to it, it does nothing.
I am using kill -2 pid
where pid is the pid of the running script.
If I hit CTRL+C (SIGINT) in terminal where the script is running it kills itself and writes the message. How come, it is not the same when sending the signal to it from a different terminal?