[pbs-devel] [PATCH proxmox v2 2/2] router: Use safe wrapper for libc::isatty

Maximiliano Sandoval m.sandoval at proxmox.com
Fri Feb 16 15:59:01 CET 2024


From: Maximiliano Sandoval R <m.sandoval at proxmox.com>

Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
 proxmox-router/src/cli/text_table.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/proxmox-router/src/cli/text_table.rs b/proxmox-router/src/cli/text_table.rs
index ea50b04b..21e466cd 100644
--- a/proxmox-router/src/cli/text_table.rs
+++ b/proxmox-router/src/cli/text_table.rs
@@ -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();
-- 
2.39.2





More information about the pbs-devel mailing list