]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
tests: improve process cleanup after config tests
authorPetr Špaček <petr.spacek@nic.cz>
Tue, 13 Oct 2020 10:53:07 +0000 (12:53 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Mon, 26 Oct 2020 13:25:13 +0000 (14:25 +0100)
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.

scripts/test-config.sh

index 3ae6c3aaeb548ca34947431ccf432c525d6d7ba2..695e5182a2e82fb7c75b3298463c54c114a6a6ec 100755 (executable)
@@ -13,8 +13,13 @@ TEST_DIR="$(dirname ${TEST_FILE})"
 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