From d4679361e87f8d145791d71cb1d813b017b0bb16 Mon Sep 17 00:00:00 2001 From: containerscrew Date: Sun, 12 Jan 2025 22:51:18 +0100 Subject: [PATCH] Fix get_process_name func --- nflux/src/utils.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nflux/src/utils.rs b/nflux/src/utils.rs index f34a792..469eb1f 100644 --- a/nflux/src/utils.rs +++ b/nflux/src/utils.rs @@ -79,11 +79,13 @@ pub fn lookup_address(ip: u32) -> String { pub fn get_process_name(pid: u64) -> String { let mut s = System::new_all(); + // Is this causing overhead? s.refresh_all(); match s.process(Pid::from(pid as usize)) { Some(process) => { - format!("{:?}", process.name()).to_string() + // Get the process name. Remove "" when have spaces or other special characters + format!("{:?}", process.name()).to_string().trim_matches('"').to_string() } None => String::new(), }