summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-12-18 20:18:30 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-12-18 20:18:30 +0000
commit5b914591c663dee799fe4f205516d7fc3e2766cc (patch)
tree6788c4a3e2c459463474cb92ae5d7d37bdaab2fb /cpukit/libmisc
parentUpdate for block device API change (diff)
downloadrtems-5b914591c663dee799fe4f205516d7fc3e2766cc.tar.bz2
2009-12-18 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/shell/login_prompt.c: Switch from non-canonical mode with timeout (Case C) to blocking IO waiting for single character on login. In Case C mode, you cannot tell EOF from no data available. This means we cannot tell when a telnet connection is dropped. This was changed from 4.9 and resulted in breakage.
Diffstat (limited to 'cpukit/libmisc')
-rw-r--r--cpukit/libmisc/shell/login_prompt.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/cpukit/libmisc/shell/login_prompt.c b/cpukit/libmisc/shell/login_prompt.c
index d277b7f0d5..5c684141d7 100644
--- a/cpukit/libmisc/shell/login_prompt.c
+++ b/cpukit/libmisc/shell/login_prompt.c
@@ -111,18 +111,18 @@ static bool rtems_shell_get_text(
return false;
case '\n':
case '\r':
- put( '\n', out);
+ put('\n', out);
line [i] = '\0';
return true;
case 127:
case '\b':
if (i > 0) {
- put( '\b', out);
- put( ' ', out);
- put( '\b', out);
+ put('\b', out);
+ put(' ', out);
+ put('\b', out);
--i;
} else {
- put( '\a', out);
+ put('\a', out);
}
break;
default:
@@ -132,10 +132,10 @@ static bool rtems_shell_get_text(
++i;
put( c, out);
} else {
- put( '\a', out);
+ put('\a', out);
}
} else {
- put( '\a', out);
+ put('\a', out);
}
break;
}
@@ -159,10 +159,13 @@ bool rtems_shell_login_prompt(
if (tcgetattr( fd_in, &termios_previous) == 0) {
struct termios termios_new = termios_previous;
+ /*
+ * Stay in canonical mode so we can tell EOF and dropped connections.
+ * But read one character at a time and do not echo it.
+ */
termios_new.c_lflag &= (unsigned char) ~ECHO;
- termios_new.c_lflag &= (unsigned char) ~ICANON;
- termios_new.c_cc [VTIME] = 255;
- termios_new.c_cc [VMIN] = 0;
+ termios_new.c_cc [VTIME] = 0;
+ termios_new.c_cc [VMIN] = 1;
restore_termios = tcsetattr( fd_in, TCSANOW, &termios_new) == 0;
}