aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dmm/dmm_scripts/kill_given_proc.sh
diff options
context:
space:
mode:
authorsharath <sharathkumarboyanapally@gmail.com>2018-08-21 11:01:26 +0530
committerPeter Mikus <pmikus@cisco.com>2018-09-27 08:18:41 +0000
commit19947738140e71d8d9fa90349e68f6261f5a612f (patch)
tree663ccab317082bf17dd5382fda754f56a57848c8 /tests/dmm/dmm_scripts/kill_given_proc.sh
parentebd0c7defaffdd6cd3ff2b5f580c86601917a0c7 (diff)
integration of DMM+lwip testscripts
Change-Id: Ifb1a0702353e71c61a694dea5164df41f4e23389 Signed-off-by: sharath <sharathkumarboyanapally@gmail.com>
Diffstat (limited to 'tests/dmm/dmm_scripts/kill_given_proc.sh')
-rwxr-xr-xtests/dmm/dmm_scripts/kill_given_proc.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/dmm/dmm_scripts/kill_given_proc.sh b/tests/dmm/dmm_scripts/kill_given_proc.sh
new file mode 100755
index 0000000000..772643a316
--- /dev/null
+++ b/tests/dmm/dmm_scripts/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