From e66c1f8e5ac0223160e17c2311fce5f3e8933b97 Mon Sep 17 00:00:00 2001 From: arehbein Date: Mon, 28 Nov 2022 22:39:21 +0100 Subject: [PATCH] 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 --- ttcn3-tcpdump-start.sh | 6 ++++-- ttcn3-tcpdump-stop.sh | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ttcn3-tcpdump-start.sh b/ttcn3-tcpdump-start.sh index aa42e62b8..c4905d92f 100755 --- a/ttcn3-tcpdump-start.sh +++ b/ttcn3-tcpdump-start.sh @@ -21,8 +21,10 @@ fi 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 } diff --git a/ttcn3-tcpdump-stop.sh b/ttcn3-tcpdump-stop.sh index b4795307f..0feaeaa9c 100755 --- a/ttcn3-tcpdump-stop.sh +++ b/ttcn3-tcpdump-stop.sh @@ -16,8 +16,10 @@ fi 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 }