ttcn3-tcpdump*.sh: Fix tcpdump procs not being killed
Also: Fix possibly empty files not being deleted.
Fixes: cf8c450ed5f9c8e9f767509fa156cf2368aaebe6
Fixes: OS#5796
Change-Id: I4e17d8313755c36f130982c921abf69d78c98ae6
diff --git a/ttcn3-tcpdump-start.sh b/ttcn3-tcpdump-start.sh
index aa42e62..c4905d9 100755
--- a/ttcn3-tcpdump-start.sh
+++ b/ttcn3-tcpdump-start.sh
@@ -21,8 +21,10 @@
kill_rm_pidfile() {
# NOTE: This requires you to be root or something like
# "laforge ALL=NOPASSWD: /usr/sbin/tcpdump, /bin/kill" in your sudoers file
- if ! [ -e "$1" ] && [ -s "$1" ]; then
- $SUDOSTR kill "$(cat "$1")" 2>&1 | grep -v "No such process"
+ if [ -e "$1" ]; then
+ if [ -s "$1" ]; then
+ $SUDOSTR kill "$(cat "$1")" 2>&1 | grep -v "No such process"
+ fi
rm $1
fi
}