FreeCalypso > hg > themwi-system-sw
changeset 37:a065b4a62a8a
themwi-test-mtc: drain stdin when we receive input
meant to request user disconnect
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 10 Jul 2022 00:32:38 -0800 |
parents | e8e82a4bf12b |
children | 020ba624bdd8 |
files | mtctest/main.c |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mtctest/main.c Sun Jul 10 00:24:19 2022 -0800 +++ b/mtctest/main.c Sun Jul 10 00:32:38 2022 -0800 @@ -13,6 +13,14 @@ extern int mtc_socket; extern int disconnect_mode; +static void +drain_stdin() +{ + char buf[256]; + + read(0, buf, sizeof buf); +} + main(argc, argv) char **argv; { @@ -58,7 +66,9 @@ } if (FD_ISSET(mtc_socket, &fds)) mtc_socket_select(); - if (!disconnect_mode && FD_ISSET(0, &fds)) + if (!disconnect_mode && FD_ISSET(0, &fds)) { + drain_stdin(); send_disconnect_req(); + } } }