summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/less.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index 79732cc..a704155 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -1251,6 +1251,9 @@ int less_main(int argc, char **argv)
* is not a tty and turns into cat. This makes sense. */
if (!isatty(STDOUT_FILENO))
return bb_cat(argv);
+ kbd_fd = open(CURRENT_TTY, O_RDONLY);
+ if (kbd_fd < 0)
+ return bb_cat(argv);
if (!num_files) {
if (isatty(STDIN_FILENO)) {
@@ -1261,8 +1264,6 @@ int less_main(int argc, char **argv)
} else
filename = xstrdup(files[0]);
- kbd_fd = xopen(CURRENT_TTY, O_RDONLY);
-
get_terminal_width_height(kbd_fd, &width, &max_displayed_line);
/* 20: two tabstops + 4 */
if (width < 20 || max_displayed_line < 3)