diff options
Diffstat (limited to 'tests/dmm/dmm_scripts/kill_given_proc.sh')
-rwxr-xr-x | tests/dmm/dmm_scripts/kill_given_proc.sh | 31 |
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 |