From af7d6cd045df5b2f18867d0d9aa3079728e73fda Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 30 Jan 2020 18:25:43 +0100 Subject: [PATCH] src/api/cli/text_table.rs: only call TIOCGWINSZ on terminals --- proxmox/src/api/cli/text_table.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/proxmox/src/api/cli/text_table.rs b/proxmox/src/api/cli/text_table.rs index c56441f0..4872912a 100644 --- a/proxmox/src/api/cli/text_table.rs +++ b/proxmox/src/api/cli/text_table.rs @@ -195,11 +195,13 @@ impl TableFormatOptions { let mut me = Self::default(); let is_tty = unsafe { libc::isatty(libc::STDOUT_FILENO) == 1 }; - let mut winsize = libc::winsize { ws_row: 0, ws_col: 0, ws_xpixel: 0, ws_ypixel: 0 }; - unsafe { libc::ioctl(libc::STDOUT_FILENO, libc::TIOCGWINSZ, &mut winsize) }; - if is_tty && (winsize.ws_col > 0) { - me.columns = Some(winsize.ws_col as usize) ; + if is_tty { + let mut winsize = libc::winsize { ws_row: 0, ws_col: 0, ws_xpixel: 0, ws_ypixel: 0 }; + unsafe { libc::ioctl(libc::STDOUT_FILENO, libc::TIOCGWINSZ, &mut winsize) }; + if winsize.ws_col > 0 { + me.columns = Some(winsize.ws_col as usize); + } } let empty_cstr = crate::c_str!("");