-#kill the dpdk application
-sudo pkill testpmd
-sudo pkill l2fwd
-sudo pkill l3fwd
-sudo rm -f ${TESTPMD_PID}
-sudo rm -f /dev/hugepages/*
-cat ${TESTPMD_LOG}
+# Try to kill the testpmd
+sudo pgrep testpmd
+if [ $? -eq "0" ]; then
+ success=false
+ sudo pkill testpmd
+ echo "RC = $?"
+ for attempt in {1..5}; do
+ echo "Checking if testpmd is still alive, attempt nr ${attempt}"
+ sudo pgrep testpmd
+ if [ $? -eq "1" ]; then
+ echo "testpmd is dead"
+ success=true
+ break
+ fi
+ echo "testpmd is still alive, waiting 1 second"
+ sleep 1
+ done
+ if [ "$success" = false ]; then
+ echo "The command sudo pkill testpmd failed"
+ sudo pkill -9 testpmd
+ echo "RC = $?"
+ exit 1
+ fi
+else
+ echo "testpmd is not running"
+fi