From c301ce0febf95d55d938c27d9dc59d94f86931ee Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 9 Nov 2024 21:13:12 +0300 Subject: [PATCH] lock stdout To help prevent race conditions, and ensuring safe output --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 790734d..ac004ef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,10 +93,11 @@ fn print_system_info(fields: &Fields) -> io::Result<()> { .max() .unwrap_or(0); - writeln!(io::stdout(), "{:<27} {} ~{RESET}", LOGO[0], user_info)?; + let mut handle = io::stdout().lock(); + writeln!(handle, "{:<27} {} ~{RESET}", LOGO[0], user_info)?; for (logo_line, (icon, label, value)) in LOGO[1..].iter().zip(system_info.iter()) { writeln!( - io::stdout(), + handle, "{:<27} {CYAN}{:<2} {BLUE}{: