shlib.sh: add explicit INT and TERM traps
commit49b4937a6fc469788c49698a2269cd6588c9578a
authorKyle J. McKay <mackyle@gmail.com>
Fri, 6 Feb 2015 11:44:11 +0000 (6 03:44 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Fri, 6 Feb 2015 11:44:11 +0000 (6 03:44 -0800)
tree9070dc729a3f61f359b29144a3a980681e31a980
parent51e10675f7494529a82ac3e9c58dbe4b96b3dbe0
shlib.sh: add explicit INT and TERM traps

In order to clean up the $bang_log file we require the EXIT trap to
run.  However, only bash arranges for EXIT to run when the shell is
killed by an uncaught signal.

Therefore install traps on both SIGINT and SIGTERM that just call
exit which causes the EXIT trap to run.  POSIX specifies that the
exit code for a process killed by a signal is 128 + signal number,
so we use those exit codes to reflect that we exited because of a
signal.

This change combined with the previous change to jobd.pl to kill
timing out jobs with SIGTERM first should finally combine to
eliminate the accumulation of temporary files in /tmp as a result
of timing out jobs being killed.
shlib.sh