I have a bash script S1 shell that launches a new script S2 shell (contains only sleep 20 ) synchronously, i.e. in the foreground.
I want the following:
When I send SIGTERM or SIGINT to S1 , both S1 and S2 should stop.
Actually this works if I run S1 at the forefront command line a, if I press CTRL-C (regardless of whether I explicitly block SIGINT in scripts or not).
When I run S1 in the background and then send it a SIGINT signal with kill -s SIGINT $! , it accepts until S2 completes its normal processing, i.e. S2 not interrupted.
My use case is the latter, and I need a way to interrupt both S1 and S2 , sending a signal only to S1 .
source share