Previously exit trap executed command "kill -9" even if there were no
leftover processes and this lead to clutter in logs because kill
complained about missing arguments.
As a bonus the cleanup routine now prints information about leftover
processes.
TMP_RUNDIR="$(mktemp -d)"
function finish {
- kill -s 9 $(jobs -p) || :
- rm -rf "${TMP_RUNDIR}"
+ if [[ "$(jobs -p)" != "" ]]
+ then
+ echo "SIGKILLing leftover processes:"
+ jobs -l
+ kill -s SIGKILL $(jobs -p)
+ fi
+ rm -rf "${TMP_RUNDIR}"
}
trap finish EXIT