]> git.proxmox.com Git - proxmox.git/commitdiff
router: Use safe wrapper for libc::isatty
authorMaximiliano Sandoval R <m.sandoval@proxmox.com>
Fri, 16 Feb 2024 14:59:01 +0000 (15:59 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 16 Feb 2024 15:56:02 +0000 (16:56 +0100)
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
proxmox-router/src/cli/text_table.rs

index ea50b04bcc6658f035a123ed20e86b0c3c1c80d8..21e466cd2269f56f9ffe5e26faf19501e6497d46 100644 (file)
@@ -1,4 +1,4 @@
-use std::io::Write;
+use std::io::{IsTerminal, Write};
 
 use anyhow::{bail, format_err, Error};
 use serde_json::Value;
@@ -245,7 +245,7 @@ impl TableFormatOptions {
     pub fn new() -> Self {
         let mut me = Self::default();
 
-        let is_tty = unsafe { libc::isatty(libc::STDOUT_FILENO) == 1 };
+        let is_tty = std::io::stdout().is_terminal();
 
         if is_tty {
             let (_rows, columns) = stdout_terminal_size();