#ifdef CONFIG_WPA_CLI_FORK
+static int in_query = 0;
+
+static void wpa_cli_monitor_sig(int sig)
+{
+ if (sig == SIGUSR1)
+ in_query = 1;
+ else if (sig == SIGUSR2)
+ in_query = 0;
+}
+
static void wpa_cli_monitor(void)
{
char buf[256];
struct timeval tv;
fd_set rfds;
+ signal(SIGUSR1, wpa_cli_monitor_sig);
+ signal(SIGUSR2, wpa_cli_monitor_sig);
+
while (mon_conn) {
int s = wpa_ctrl_get_fd(mon_conn);
tv.tv_sec = 5;
FD_ZERO(&rfds);
FD_SET(s, &rfds);
if (select(s + 1, &rfds, NULL, NULL, &tv) < 0) {
+ if (errno == EINTR)
+ continue;
perror("select");
break;
}
break;
}
buf[len] = '\0';
+ if (in_query)
+ printf("\r");
printf("%s\n", buf);
+ kill(getppid(), SIGUSR1);
}
}
}
wpa_cli_action_process(buf);
else {
if (in_read && first)
- printf("\n");
+ printf("\r");
first = 0;
printf("%s\n", buf);
+#ifdef CONFIG_READLINE
+ rl_on_new_line();
+ rl_redisplay();
+#endif /* CONFIG_READLINE */
}
} else {
printf("Could not read pending message.\n");
#ifndef CONFIG_NATIVE_WINDOWS
alarm(ping_interval);
#endif /* CONFIG_NATIVE_WINDOWS */
+#ifdef CONFIG_WPA_CLI_FORK
+ if (mon_pid)
+ kill(mon_pid, SIGUSR1);
+#endif /* CONFIG_WPA_CLI_FORK */
#ifdef CONFIG_READLINE
cmd = readline("> ");
if (cmd && *cmd) {
if (cmd != cmdbuf)
free(cmd);
+#ifdef CONFIG_WPA_CLI_FORK
+ if (mon_pid)
+ kill(mon_pid, SIGUSR2);
+#endif /* CONFIG_WPA_CLI_FORK */
} while (!wpa_cli_quit);
#ifdef CONFIG_READLINE
}
+#ifdef CONFIG_WPA_CLI_FORK
+static void wpa_cli_usr1(int sig)
+{
+#ifdef CONFIG_READLINE
+ rl_on_new_line();
+ rl_redisplay();
+#endif /* CONFIG_READLINE */
+}
+#endif /* CONFIG_WPA_CLI_FORK */
+
+
#ifndef CONFIG_NATIVE_WINDOWS
static void wpa_cli_alarm(int sig)
{
#ifndef CONFIG_NATIVE_WINDOWS
signal(SIGALRM, wpa_cli_alarm);
#endif /* CONFIG_NATIVE_WINDOWS */
+#ifdef CONFIG_WPA_CLI_FORK
+ signal(SIGUSR1, wpa_cli_usr1);
+#endif /* CONFIG_WPA_CLI_FORK */
if (ctrl_ifname == NULL)
ctrl_ifname = wpa_cli_get_default_ifname();