diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-01-15 22:58:06 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-01-15 22:58:06 +0100 |
commit | 7ce209b9d4f6053b7e6d07dec66e382bc3614c35 (patch) | |
tree | 5e4aaaf494f771b61707bc12df849c01ad9e37c0 /shell | |
parent | d29ae7e071a11c51436922654c2de73a8ac36333 (diff) | |
download | busybox-w32-7ce209b9d4f6053b7e6d07dec66e382bc3614c35.tar.gz busybox-w32-7ce209b9d4f6053b7e6d07dec66e382bc3614c35.tar.bz2 busybox-w32-7ce209b9d4f6053b7e6d07dec66e382bc3614c35.zip |
shell_builtin_read: set cc[VMIN] to 1; lineedit: don't clear c_cc[VINTR]
First change fixes "read -n NUM". Apparently poll() won't report
data availability if cc[VMIN] > 1 until there are at least cc[VMIN] bytes.
function old new delta
read_line_input 3885 3877 -8
shell_builtin_read 1097 1087 -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18) Total: -18 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/shell_common.c | 8 |
1 files changed, 7 insertions, 1 deletions
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); |