From b38465c6d15604c9fb807633f784a39d7046382a Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 25 Jun 2017 13:56:04 +0200 Subject: firemon: only use col/row when values are valid In case stdin (or stdout/stderr) is not attached to a tty, the ioctl can't determine the actual sizes, so keep using fallback values. --- src/firemon/top.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/firemon/top.c') diff --git a/src/firemon/top.c b/src/firemon/top.c index 55a35d93d..3a79a5260 100644 --- a/src/firemon/top.c +++ b/src/firemon/top.c @@ -275,8 +275,10 @@ void top(void) { int row = 24; int col = 80; if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &sz)) { - col = sz.ws_col; - row = sz.ws_row; + if (sz.ws_col > 0 && sz.ws_row > 0) { + col = sz.ws_col; + row = sz.ws_row; + } } // start printing -- cgit v1.2.3-54-g00ecf