I'm running Terraform from a script in a pipeline. I would like to ensure that if the pipeline job is aborted, Terraform receives SIGTERM.
_term() {
tf_pid="$(pidof terraform)"
kill -TERM ${tf_pid}
wait ${tf_pid}
}
trap _term SIGTERM
...
...
...
terraform "$@"
With this approach, SIGTERM is not propagated. However, it is propagated if I call terraform
this way in my script:
terraform "$@" & wait $!
Why is that?