aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/ttysize.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/miscutils/ttysize.c b/miscutils/ttysize.c
index 135ce8535..cba65b148 100644
--- a/miscutils/ttysize.c
+++ b/miscutils/ttysize.c
@@ -25,7 +25,7 @@
25//usage:#define ttysize_trivial_usage 25//usage:#define ttysize_trivial_usage
26//usage: "[w] [h]" 26//usage: "[w] [h]"
27//usage:#define ttysize_full_usage "\n\n" 27//usage:#define ttysize_full_usage "\n\n"
28//usage: "Print dimension(s) of stdin's terminal, on error return 80x25" 28//usage: "Print dimensions of stdin tty, or 80x24"
29 29
30#include "libbb.h" 30#include "libbb.h"
31 31
@@ -37,7 +37,10 @@ int ttysize_main(int argc UNUSED_PARAM, char **argv)
37 37
38 w = 80; 38 w = 80;
39 h = 24; 39 h = 24;
40 if (!ioctl(0, TIOCGWINSZ, &wsz)) { 40 if (ioctl(0, TIOCGWINSZ, &wsz) == 0
41 || ioctl(1, TIOCGWINSZ, &wsz) == 0
42 || ioctl(2, TIOCGWINSZ, &wsz) == 0
43 ) {
41 w = wsz.ws_col; 44 w = wsz.ws_col;
42 h = wsz.ws_row; 45 h = wsz.ws_row;
43 } 46 }