summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJefferson Delfes <jefferson.delfes@gmail.com>2013-12-02 09:42:38 -0400
committerJefferson Delfes <jefferson.delfes@gmail.com>2013-12-02 12:12:05 -0400
commitf7849c4f452b9cf3f4fea1bbbea4662c1e904cf6 (patch)
tree735c3343061a98a55365076f1e446ba4b1140de8
parent713c8baad42915e32c2d07a4ee6a8b81197cb758 (diff)
Test for EOF on getchar
If something gone wrong reading char, we need to break main loop.
-rw-r--r--btctl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/btctl.c b/btctl.c
index 94ccb1b..609df44 100644
--- a/btctl.c
+++ b/btctl.c
@@ -2070,6 +2070,12 @@ int main(int argc, char *argv[]) {
while (!u.quit) {
int c = getchar();
+ if (c == EOF) {
+ rl_printf("error reading input, exiting...\n");
+ u.quit = true;
+ break;
+ }
+
/* if we are in consent bonding process, we need only a char */
if (u.prompt_state == SSP_CONSENT_PSTATE) {
c = toupper(c);