]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
ctl-d crap (i still would not recommend doing it
authorBrian West <brian@freeswitch.org>
Tue, 19 Dec 2006 19:15:13 +0000 (19:15 +0000)
committerBrian West <brian@freeswitch.org>
Tue, 19 Dec 2006 19:15:13 +0000 (19:15 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3729 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_console.c

index 61f606a3b206afc7d6698ef9073b5aa1489df8b9..be11823b0431168c9b696825bc0c8b64784c56b5 100644 (file)
@@ -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;