FreeCalypso > hg > themwi-system-sw
comparison mtctest/main.c @ 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 | c8e9b295e88f |
comparison
equal
deleted
inserted
replaced
36:e8e82a4bf12b | 37:a065b4a62a8a |
---|---|
10 #include <syslog.h> | 10 #include <syslog.h> |
11 #include <unistd.h> | 11 #include <unistd.h> |
12 | 12 |
13 extern int mtc_socket; | 13 extern int mtc_socket; |
14 extern int disconnect_mode; | 14 extern int disconnect_mode; |
15 | |
16 static void | |
17 drain_stdin() | |
18 { | |
19 char buf[256]; | |
20 | |
21 read(0, buf, sizeof buf); | |
22 } | |
15 | 23 |
16 main(argc, argv) | 24 main(argc, argv) |
17 char **argv; | 25 char **argv; |
18 { | 26 { |
19 extern int optind; | 27 extern int optind; |
56 perror("select"); | 64 perror("select"); |
57 exit(1); | 65 exit(1); |
58 } | 66 } |
59 if (FD_ISSET(mtc_socket, &fds)) | 67 if (FD_ISSET(mtc_socket, &fds)) |
60 mtc_socket_select(); | 68 mtc_socket_select(); |
61 if (!disconnect_mode && FD_ISSET(0, &fds)) | 69 if (!disconnect_mode && FD_ISSET(0, &fds)) { |
70 drain_stdin(); | |
62 send_disconnect_req(); | 71 send_disconnect_req(); |
72 } | |
63 } | 73 } |
64 } | 74 } |