I have a bash shell script S1
that starts another shell script S2
(contains just sleep 20
) synchronously, i.e. in the foreground.
What I want is the following:
When I send SIGTERM or SIGINT to S1
, both S1
and S2
should stop.
Actually that works if I start S1
on the command line in the foreground an if I press CTRL-C (independent of whether I trap SIGINT in the scripts explicitly or not).
When I start S1
in the background and then send it the SIGINT signal with kill -s SIGINT $!
it takes until S2
terminates its normal processing, i.e. S2
is not interrupted.
My use case is the latter and I a need a way to interrupt both S1
and S2
by sending a signal just to S1
.