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

Maximiliano Sandoval R m.sandoval at proxmox.com
Fri Nov 17 13:37:39 CET 2023


Signed-off-by: Maximiliano Sandoval R <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 9bc7210..3368605 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, 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