wpa_cli: Redisplay readline edit after event messages
This commit is contained in:
parent
036f7c4aab
commit
dd63f314bd
1 changed files with 45 additions and 1 deletions
|
@ -128,6 +128,16 @@ static void usage(void)
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_WPA_CLI_FORK
|
#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)
|
static void wpa_cli_monitor(void)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
@ -135,6 +145,9 @@ static void wpa_cli_monitor(void)
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
|
|
||||||
|
signal(SIGUSR1, wpa_cli_monitor_sig);
|
||||||
|
signal(SIGUSR2, wpa_cli_monitor_sig);
|
||||||
|
|
||||||
while (mon_conn) {
|
while (mon_conn) {
|
||||||
int s = wpa_ctrl_get_fd(mon_conn);
|
int s = wpa_ctrl_get_fd(mon_conn);
|
||||||
tv.tv_sec = 5;
|
tv.tv_sec = 5;
|
||||||
|
@ -142,6 +155,8 @@ static void wpa_cli_monitor(void)
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
FD_SET(s, &rfds);
|
FD_SET(s, &rfds);
|
||||||
if (select(s + 1, &rfds, NULL, NULL, &tv) < 0) {
|
if (select(s + 1, &rfds, NULL, NULL, &tv) < 0) {
|
||||||
|
if (errno == EINTR)
|
||||||
|
continue;
|
||||||
perror("select");
|
perror("select");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +170,10 @@ static void wpa_cli_monitor(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
if (in_query)
|
||||||
|
printf("\r");
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
|
kill(getppid(), SIGUSR1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1841,9 +1859,13 @@ static void wpa_cli_recv_pending(struct wpa_ctrl *ctrl, int in_read,
|
||||||
wpa_cli_action_process(buf);
|
wpa_cli_action_process(buf);
|
||||||
else {
|
else {
|
||||||
if (in_read && first)
|
if (in_read && first)
|
||||||
printf("\n");
|
printf("\r");
|
||||||
first = 0;
|
first = 0;
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
|
#ifdef CONFIG_READLINE
|
||||||
|
rl_on_new_line();
|
||||||
|
rl_redisplay();
|
||||||
|
#endif /* CONFIG_READLINE */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("Could not read pending message.\n");
|
printf("Could not read pending message.\n");
|
||||||
|
@ -1930,6 +1952,10 @@ static void wpa_cli_interactive(void)
|
||||||
#ifndef CONFIG_NATIVE_WINDOWS
|
#ifndef CONFIG_NATIVE_WINDOWS
|
||||||
alarm(ping_interval);
|
alarm(ping_interval);
|
||||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||||
|
#ifdef CONFIG_WPA_CLI_FORK
|
||||||
|
if (mon_pid)
|
||||||
|
kill(mon_pid, SIGUSR1);
|
||||||
|
#endif /* CONFIG_WPA_CLI_FORK */
|
||||||
#ifdef CONFIG_READLINE
|
#ifdef CONFIG_READLINE
|
||||||
cmd = readline("> ");
|
cmd = readline("> ");
|
||||||
if (cmd && *cmd) {
|
if (cmd && *cmd) {
|
||||||
|
@ -1985,6 +2011,10 @@ static void wpa_cli_interactive(void)
|
||||||
|
|
||||||
if (cmd != cmdbuf)
|
if (cmd != cmdbuf)
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
#ifdef CONFIG_WPA_CLI_FORK
|
||||||
|
if (mon_pid)
|
||||||
|
kill(mon_pid, SIGUSR2);
|
||||||
|
#endif /* CONFIG_WPA_CLI_FORK */
|
||||||
} while (!wpa_cli_quit);
|
} while (!wpa_cli_quit);
|
||||||
|
|
||||||
#ifdef CONFIG_READLINE
|
#ifdef CONFIG_READLINE
|
||||||
|
@ -2074,6 +2104,17 @@ static void wpa_cli_terminate(int sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#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
|
#ifndef CONFIG_NATIVE_WINDOWS
|
||||||
static void wpa_cli_alarm(int sig)
|
static void wpa_cli_alarm(int sig)
|
||||||
{
|
{
|
||||||
|
@ -2221,6 +2262,9 @@ int main(int argc, char *argv[])
|
||||||
#ifndef CONFIG_NATIVE_WINDOWS
|
#ifndef CONFIG_NATIVE_WINDOWS
|
||||||
signal(SIGALRM, wpa_cli_alarm);
|
signal(SIGALRM, wpa_cli_alarm);
|
||||||
#endif /* CONFIG_NATIVE_WINDOWS */
|
#endif /* CONFIG_NATIVE_WINDOWS */
|
||||||
|
#ifdef CONFIG_WPA_CLI_FORK
|
||||||
|
signal(SIGUSR1, wpa_cli_usr1);
|
||||||
|
#endif /* CONFIG_WPA_CLI_FORK */
|
||||||
|
|
||||||
if (ctrl_ifname == NULL)
|
if (ctrl_ifname == NULL)
|
||||||
ctrl_ifname = wpa_cli_get_default_ifname();
|
ctrl_ifname = wpa_cli_get_default_ifname();
|
||||||
|
|
Loading…
Reference in a new issue