3 ms·
(posted to blog comments as well) If you decide to trap INT or TERM, it would be wise to properly kill your process with INT or TERM: # if you're using ba
by guns 17y ago
(posted to blog comments as well)
If you decide to trap INT or TERM, it would be wise to properly kill your process with INT or TERM:
# if you're using bash, you can use $BASHPID in place of $$
for sig in INT TERM EXIT; do
trap "rm -f \"\$TMPFILE\"; [[ $sig == EXIT ]] || kill -$sig $$" $sig
done
Not propagating signals in this manner is being a bad Unix citizen. Bash would have re-raised the SIGNAL, so you should too.
For more information: http://www.cons.org/cracauer/sigint.html http://www.cons.org/cracauer/sigint.html
- liraz 17y agoI haven't run into any problems (yet) obstructing signal propagation in my scripts but as you point out it's not The Correct Thing To Do. For the sake of correctness I'll be updating my error handling code. I find doing the correct thing often saves me from debugging strange edge cases. (replied to on blog comments as well)