summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/8021x14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/8021x b/src/8021x
index d143b30..e5047a2 100644
--- a/src/8021x
+++ b/src/8021x
@@ -38,21 +38,19 @@ start_wpa()
fi
wpa_supplicant -B -P "/run/wpa_supplicant_${INTERFACE}.pid" -i "$INTERFACE" -D "$WPA_DRIVER" "$WPA_CONF" $WPA_OPTS
- sleep 1
- if [[ ! -f "/run/wpa_supplicant_${INTERFACE}.pid" ]]; then
- return 1
- fi
+ # wait up to one second for the pid file to appear
+ timeout_wait 1 '[[ -f "/run/wpa_supplicant_${INTERFACE}.pid" ]]';
+ return $?
}
stop_wpa()
{
wpa_cli -p "$WPA_CTRL_PATH" -i "$1" terminate &> /dev/null
- sleep 1 # JP: need this else the file tends to disappear after [[ -f ... ]] but before cat...
- # see <http://bbs.archlinux.org/viewtopic.php?pid=515667#p515667>
- if [[ -f "/run/wpa_supplicant_$1.pid" ]]; then
+
+ # wait up to one second for the pid file to be removed
+ timeout_wait 1 '[[ ! -f "/run/wpa_supplicant_$1.pid" ]]' || \
kill "$(< "/run/wpa_supplicant_$1.pid")" &>/dev/null &
- fi
}
wpa_reconfigure() {