]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Kill hostapd/wpa_supplicant more forcefully if needed
authorJouni Malinen <j@w1.fi>
Mon, 26 Aug 2013 13:38:13 +0000 (16:38 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 26 Aug 2013 13:38:13 +0000 (16:38 +0300)
Try to make sure new testing can be started by forcing
hostapd/wpa_supplicant to be killed with SIGKILL if needed. In addition,
wait a bit longer when killing the processes to avoid issues with the
next test run starting before the old one has been fully terminated.

Signed-hostap: Jouni Malinen <j@w1.fi>

tests/hwsim/stop-wifi.sh

index a4255bada0007680bf6b3a2a0825dfcc3c3d1145..184ce8467015eaaee6e89ec9a1a18233f61ca594 100755 (executable)
@@ -1,5 +1,11 @@
 #!/bin/sh
 
+if pidof wpa_supplicant hostapd > /dev/null; then
+    RUNNING=yes
+else
+    RUNNING=no
+fi
+
 sudo killall -q hostapd
 sudo killall -q wpa_supplicant
 for i in `pidof valgrind.bin`; do
@@ -12,6 +18,29 @@ sudo killall -q tcpdump
 if grep -q hwsim0 /proc/net/dev; then
     sudo ifconfig hwsim0 down
 fi
+
+if [ "$RUNNING" = "yes" ]; then
+    # give some time for hostapd and wpa_supplicant to complete deinit
+    sleep 2
+fi
+
+if pidof wpa_supplicant hostapd > /dev/null; then
+    echo "wpa_supplicant/hostapd did not exit - try to force them to die"
+    sudo killall -9 -q hostapd
+    sudo killall -9 -q wpa_supplicant
+    sleep 5
+fi
+
+for i in `pidof valgrind.bin`; do
+    if ps $i | grep -q -E "wpa_supplicant|hostapd"; then
+       echo "wpa_supplicant/hostapd(valgrind) did not exit - try to force it to die"
+       sudo kill -9 $i
+    fi
+done
+
 if grep -q mac80211_hwsim /proc/modules ; then
     sudo rmmod mac80211_hwsim 
+    # wait at the end to avoid issues starting something new immediately after
+    # this script returns
+    sleep 1
 fi