summaryrefslogtreecommitdiffstats
path: root/scripts/csit/kill_given_proc.sh
diff options
context:
space:
mode:
authoryalei wang <wylandrea@gmail.com>2018-10-11 05:56:23 +0000
committerGerrit Code Review <gerrit@fd.io>2018-10-11 05:56:23 +0000
commitaf0587ee6e44e9057ff6047a00fcd9015df1f5a1 (patch)
treefe724da945b95fe6930fbe44f7bdab8416d6cf25 /scripts/csit/kill_given_proc.sh
parentae849b5788d5c0f6633e65d8daa2fe0779029a69 (diff)
parentdd82eab81846cbccaa1ab84c5a9919dc0b41f9c9 (diff)
Merge "Feat: Migration of CSIT scripts to DMM repo"
Diffstat (limited to 'scripts/csit/kill_given_proc.sh')
-rwxr-xr-xscripts/csit/kill_given_proc.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/csit/kill_given_proc.sh b/scripts/csit/kill_given_proc.sh
new file mode 100755
index 0000000..772643a
--- /dev/null
+++ b/scripts/csit/kill_given_proc.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+proc_name=$1
+sudo pgrep $proc_name
+if [ $? -eq "0" ]; then
+ success=false
+ sudo pkill $proc_name
+ echo "RC = $?"
+ for attempt in {1..5}; do
+ echo "Checking if '$proc_name' is still alive, attempt nr ${attempt}"
+ sudo pgrep $proc_name
+ if [ $? -eq "1" ]; then
+ echo "'$proc_name' is dead"
+ success=true
+ break
+ fi
+ echo "'$proc_name' is still alive, waiting 1 second"
+ sleep 1
+ done
+ if [ "$success" = false ]; then
+ echo "The command sudo pkill '$proc_name' failed"
+ sudo pkill -9 $proc_name
+ echo "RC = $?"
+ exit 1
+ fi
+else
+ echo "'$proc_name' is not running"
+fi
+
+sleep 2
+exit 0 \ No newline at end of file