diff options
-rw-r--r-- | libbb/lineedit.c | 15 | ||||
-rw-r--r-- | shell/shell_common.c | 8 |
2 files changed, 16 insertions, 7 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 1390ed62d..460e27fed 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 | |||
2206 | #define command command_must_not_be_used | 2206 | #define command command_must_not_be_used |
2207 | 2207 | ||
2208 | new_settings = initial_settings; | 2208 | new_settings = initial_settings; |
2209 | new_settings.c_lflag &= ~ICANON; /* unbuffered input */ | 2209 | /* ~ICANON: unbuffered input (most c_cc[] are disabled, VMIN/VTIME are enabled) */ |
2210 | /* Turn off echoing and CTRL-C, so we can trap it */ | 2210 | /* ~ECHO, ~ECHONL: turn off echoing, including newline echoing */ |
2211 | new_settings.c_lflag &= ~(ECHO | ECHONL | ISIG); | 2211 | /* ~ISIG: turn off INTR (ctrl-C), QUIT, SUSP */ |
2212 | /* Hmm, in linux c_cc[] is not parsed if ICANON is off */ | 2212 | new_settings.c_lflag &= ~(ICANON | ECHO | ECHONL | ISIG); |
2213 | /* reads would block only if < 1 char is available */ | ||
2213 | new_settings.c_cc[VMIN] = 1; | 2214 | new_settings.c_cc[VMIN] = 1; |
2215 | /* no timeout (reads block forever) */ | ||
2214 | new_settings.c_cc[VTIME] = 0; | 2216 | new_settings.c_cc[VTIME] = 0; |
2215 | /* Turn off CTRL-C, so we can trap it */ | 2217 | /* Should be not needed if ISIG is off: */ |
2216 | new_settings.c_cc[VINTR] = _POSIX_VDISABLE; | 2218 | /* Turn off CTRL-C */ |
2219 | /* new_settings.c_cc[VINTR] = _POSIX_VDISABLE; */ | ||
2217 | tcsetattr_stdin_TCSANOW(&new_settings); | 2220 | tcsetattr_stdin_TCSANOW(&new_settings); |
2218 | 2221 | ||
2219 | #if ENABLE_USERNAME_OR_HOMEDIR | 2222 | #if ENABLE_USERNAME_OR_HOMEDIR |
diff --git a/shell/shell_common.c b/shell/shell_common.c index bbc22ed34..51c92d60e 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), | |||
138 | old_tty = tty; | 138 | old_tty = tty; |
139 | if (nchars) { | 139 | if (nchars) { |
140 | tty.c_lflag &= ~ICANON; | 140 | tty.c_lflag &= ~ICANON; |
141 | tty.c_cc[VMIN] = nchars < 256 ? nchars : 255; | 141 | // Setting it to more than 1 breaks poll(): |
142 | // it blocks even if there's data. !?? | ||
143 | //tty.c_cc[VMIN] = nchars < 256 ? nchars : 255; | ||
144 | /* reads would block only if < 1 char is available */ | ||
145 | tty.c_cc[VMIN] = 1; | ||
146 | /* no timeout (reads block forever) */ | ||
147 | tty.c_cc[VTIME] = 0; | ||
142 | } | 148 | } |
143 | if (read_flags & BUILTIN_READ_SILENT) { | 149 | if (read_flags & BUILTIN_READ_SILENT) { |
144 | tty.c_lflag &= ~(ECHO | ECHOK | ECHONL); | 150 | tty.c_lflag &= ~(ECHO | ECHOK | ECHONL); |