mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-21 14:32:39 +00:00
src/api/cli/text_table.rs: only call TIOCGWINSZ on terminals
This commit is contained in:
parent
9976f04357
commit
af7d6cd045
@ -195,11 +195,13 @@ impl TableFormatOptions {
|
|||||||
let mut me = Self::default();
|
let mut me = Self::default();
|
||||||
|
|
||||||
let is_tty = unsafe { libc::isatty(libc::STDOUT_FILENO) == 1 };
|
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) {
|
if is_tty {
|
||||||
me.columns = Some(winsize.ws_col as usize) ;
|
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!("");
|
let empty_cstr = crate::c_str!("");
|
||||||
|
Loading…
Reference in New Issue
Block a user