aboutsummaryrefslogtreecommitdiffstats
path: root/src/firemon
diff options
context:
space:
mode:
authorLibravatar Reiner Herrmann <reiner@reiner-h.de>2017-06-25 13:56:04 +0200
committerLibravatar Reiner Herrmann <reiner@reiner-h.de>2017-06-25 13:56:04 +0200
commitb38465c6d15604c9fb807633f784a39d7046382a (patch)
tree5461ebf90eb8f2c6342d0f64a7f201db18eaccf8 /src/firemon
parentfiremon: use macro instead of number (diff)
downloadfirejail-b38465c6d15604c9fb807633f784a39d7046382a.tar.gz
firejail-b38465c6d15604c9fb807633f784a39d7046382a.tar.zst
firejail-b38465c6d15604c9fb807633f784a39d7046382a.zip
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.
Diffstat (limited to 'src/firemon')
-rw-r--r--src/firemon/top.c6
1 files changed, 4 insertions, 2 deletions
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) {
275 int row = 24; 275 int row = 24;
276 int col = 80; 276 int col = 80;
277 if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &sz)) { 277 if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &sz)) {
278 col = sz.ws_col; 278 if (sz.ws_col > 0 && sz.ws_row > 0) {
279 row = sz.ws_row; 279 col = sz.ws_col;
280 row = sz.ws_row;
281 }
280 } 282 }
281 283
282 // start printing 284 // start printing