From 894ea319838cbfd75b00f08518bca41a9c8e060c Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Tue, 13 Aug 2024 10:14:04 +0800 Subject: [PATCH] Update `sysinfo` API calls (#421) - Fixes #420 --- src/os/windows.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/os/windows.rs b/src/os/windows.rs index 620a4ba..e14b33c 100644 --- a/src/os/windows.rs +++ b/src/os/windows.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use netstat2::*; -use sysinfo::{Pid, System}; +use sysinfo::{Pid, ProcessesToUpdate, System}; use crate::{ network::{LocalSocket, Protocol}, @@ -13,7 +13,7 @@ pub(crate) fn get_open_sockets() -> OpenSockets { let mut open_sockets = HashMap::new(); let mut sysinfo = System::new_all(); - sysinfo.refresh_processes(); + sysinfo.refresh_processes(ProcessesToUpdate::All); let af_flags = AddressFamilyFlags::IPV4 | AddressFamilyFlags::IPV6; let proto_flags = ProtocolFlags::TCP | ProtocolFlags::UDP; @@ -25,7 +25,7 @@ pub(crate) fn get_open_sockets() -> OpenSockets { .associated_pids .into_iter() .find_map(|pid| sysinfo.process(Pid::from_u32(pid))) - .map(|p| ProcessInfo::new(p.name(), p.pid().as_u32())) + .map(|p| ProcessInfo::new(&p.name().to_string_lossy(), p.pid().as_u32())) .unwrap_or_default(); match si.protocol_socket_info {