aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2010-03-12 15:34:56 (GMT)
committerJouni Malinen <j@w1.fi>2010-03-12 15:34:56 (GMT)
commit037f83eb4464cced3e912865a70100585b885f0d (patch)
tree8ad5faaca454392146fb4c80553bf9e198c0935f
parentdd63f314bd8c7f292a4aa6abed4700328e78b2e6 (diff)
downloadhostap-037f83eb4464cced3e912865a70100585b885f0d.zip
hostap-037f83eb4464cced3e912865a70100585b885f0d.tar.gz
hostap-037f83eb4464cced3e912865a70100585b885f0d.tar.bz2
wpa_cli: Fix detach race with forked monitor process
Need to kill the monitor process before running detach command on the monitor connection to avoid race where the monitor process may end up getting the detach command result.
-rw-r--r--wpa_supplicant/wpa_cli.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index 454852c..924ad96 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -255,6 +255,15 @@ static void wpa_cli_close_connection(void)
if (ctrl_conn == NULL)
return;
+#ifdef CONFIG_WPA_CLI_FORK
+ if (mon_pid) {
+ int status;
+ kill(mon_pid, SIGPIPE);
+ wait(&status);
+ mon_pid = 0;
+ }
+#endif /* CONFIG_WPA_CLI_FORK */
+
if (wpa_cli_attached) {
wpa_ctrl_detach(interactive ? mon_conn : ctrl_conn);
wpa_cli_attached = 0;
@@ -265,14 +274,6 @@ static void wpa_cli_close_connection(void)
wpa_ctrl_close(mon_conn);
mon_conn = NULL;
}
-#ifdef CONFIG_WPA_CLI_FORK
- if (mon_pid) {
- int status;
- kill(mon_pid, SIGPIPE);
- wait(&status);
- mon_pid = 0;
- }
-#endif /* CONFIG_WPA_CLI_FORK */
}