Skip to content

Commit 894ea31

Browse files
authored
Update sysinfo API calls (#421)
- Fixes #420
1 parent 4dba563 commit 894ea31

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/os/windows.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
22

33
use netstat2::*;
4-
use sysinfo::{Pid, System};
4+
use sysinfo::{Pid, ProcessesToUpdate, System};
55

66
use crate::{
77
network::{LocalSocket, Protocol},
@@ -13,7 +13,7 @@ pub(crate) fn get_open_sockets() -> OpenSockets {
1313
let mut open_sockets = HashMap::new();
1414

1515
let mut sysinfo = System::new_all();
16-
sysinfo.refresh_processes();
16+
sysinfo.refresh_processes(ProcessesToUpdate::All);
1717

1818
let af_flags = AddressFamilyFlags::IPV4 | AddressFamilyFlags::IPV6;
1919
let proto_flags = ProtocolFlags::TCP | ProtocolFlags::UDP;
@@ -25,7 +25,7 @@ pub(crate) fn get_open_sockets() -> OpenSockets {
2525
.associated_pids
2626
.into_iter()
2727
.find_map(|pid| sysinfo.process(Pid::from_u32(pid)))
28-
.map(|p| ProcessInfo::new(p.name(), p.pid().as_u32()))
28+
.map(|p| ProcessInfo::new(&p.name().to_string_lossy(), p.pid().as_u32()))
2929
.unwrap_or_default();
3030

3131
match si.protocol_socket_info {

0 commit comments

Comments
 (0)