I have the following script s2:
#!/bin/bash
trap 't' INT
function t() {
echo "trap"
}
sleep 999
Then I am calling s1:
#!/bin/bash
./s2 &
wait
So s1 waits for s2 which sleeps. Now when I press Ctrl+C it does not print the trap message in s2. Why is that?
Moreover if in s1 you kill s2 explicitly after launching it with INT signal, it still wont call the interrupt.
#!/bin/bash
./s2 &
pid=$!
kill -INT $pid
wait # waits for s2 instead of killing it right away
Why?