summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/lineedit.c15
-rw-r--r--shell/shell_common.c8
2 files changed, 16 insertions, 7 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 1390ed6..460e27f 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -2206,14 +2206,17 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
#define command command_must_not_be_used
new_settings = initial_settings;
- new_settings.c_lflag &= ~ICANON; /* unbuffered input */
- /* Turn off echoing and CTRL-C, so we can trap it */
- new_settings.c_lflag &= ~(ECHO | ECHONL | ISIG);
- /* Hmm, in linux c_cc[] is not parsed if ICANON is off */
+ /* ~ICANON: unbuffered input (most c_cc[] are disabled, VMIN/VTIME are enabled) */
+ /* ~ECHO, ~ECHONL: turn off echoing, including newline echoing */
+ /* ~ISIG: turn off INTR (ctrl-C), QUIT, SUSP */
+ new_settings.c_lflag &= ~(ICANON | ECHO | ECHONL | ISIG);
+ /* reads would block only if < 1 char is available */
new_settings.c_cc[VMIN] = 1;
+ /* no timeout (reads block forever) */
new_settings.c_cc[VTIME] = 0;
- /* Turn off CTRL-C, so we can trap it */
- new_settings.c_cc[VINTR] = _POSIX_VDISABLE;
+ /* Should be not needed if ISIG is off: */
+ /* Turn off CTRL-C */
+ /* new_settings.c_cc[VINTR] = _POSIX_VDISABLE; */
tcsetattr_stdin_TCSANOW(&new_settings);
#if ENABLE_USERNAME_OR_HOMEDIR
diff --git a/shell/shell_common.c b/shell/shell_common.c
index bbc22ed..51c92d6 100644
--- a/shell/shell_common.c
+++ b/shell/shell_common.c
@@ -138,7 +138,13 @@ shell_builtin_read(void FAST_FUNC (*setvar)(const char *name, const char *val),
old_tty = tty;
if (nchars) {
tty.c_lflag &= ~ICANON;
- tty.c_cc[VMIN] = nchars < 256 ? nchars : 255;
+ // Setting it to more than 1 breaks poll():
+ // it blocks even if there's data. !??
+ //tty.c_cc[VMIN] = nchars < 256 ? nchars : 255;
+ /* reads would block only if < 1 char is available */
+ tty.c_cc[VMIN] = 1;
+ /* no timeout (reads block forever) */
+ tty.c_cc[VTIME] = 0;
}
if (read_flags & BUILTIN_READ_SILENT) {
tty.c_lflag &= ~(ECHO | ECHOK | ECHONL);