From d5acc6493c1e25ebe68031162bf96d899fcd7ab6 Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 19 Dec 2006 19:15:13 +0000 Subject: [PATCH] ctl-d crap (i still would not recommend doing it git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3729 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_console.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/switch_console.c b/src/switch_console.c index 61f606a3b2..be11823b04 100644 --- a/src/switch_console.c +++ b/src/switch_console.c @@ -224,11 +224,14 @@ SWITCH_DECLARE(void) switch_console_loop(void) FD_ZERO(&efds); FD_SET(fileno(stdin), &rfds); FD_SET(fileno(stdin), &efds); - activity = select(fileno(stdin)+1, &rfds, NULL, &efds, &tv); + if ((activity = select(fileno(stdin)+1, &rfds, NULL, &efds, &tv)) < 0) { + break; + } #ifdef _MSC_VER #pragma warning(pop) #endif + if (activity == 0) { fflush(stdout); continue; @@ -236,7 +239,15 @@ SWITCH_DECLARE(void) switch_console_loop(void) memset(&cmd, 0, sizeof(cmd)); for (x = 0; x < (sizeof(cmd)-1); x++) { - cmd[x] = (char) getchar(); + int c = getchar(); + if (c < 0) { + int y = read(fileno(stdin), cmd, sizeof(cmd)); + cmd[y-1] = '\0'; + break; + } + + cmd[x] = (char) c; + if (cmd[x] == '\n') { cmd[x] = '\0'; break;