GNU/Linux: Fix the example to cancel the input on timeout.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka
2021-02-10 10:18:42 +09:00
parent c1433f1520
commit b491d815e5
4 changed files with 20 additions and 8 deletions

View File

@@ -905,7 +905,17 @@ tty_recv (struct tty *t, char *buf, uint32_t *timeout)
r = check_rx (t);
chopstx_mutex_unlock (&t->mtx);
if (r || (timeout != NULL && *timeout == 0))
break;
{
/* Cancel the input. */
for (i = 0; i < t->inputline_len; i++)
{
tty_echo_char (t, 0x08);
tty_echo_char (t, 0x20);
tty_echo_char (t, 0x08);
}
t->inputline_len = 0;
break;
}
}
chopstx_mutex_lock (&t->mtx);