Skip to content

Commit c2af633

Browse files
committed
build: update sysinfo
1 parent ebccdd1 commit c2af633

File tree

5 files changed

+41
-64
lines changed

5 files changed

+41
-64
lines changed

Cargo.lock

Lines changed: 25 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

devolutions-gateway/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ anyhow = "1.0"
6060
thiserror = "2"
6161
typed-builder = "0.21"
6262
backoff = "0.4"
63-
sysinfo = "0.30"
63+
sysinfo = { version = "0.35", default-features = false, features = ["disk"] }
6464
dunce = "1.0"
6565
bitflags = "2.9"
6666

jetsocat/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ anyhow = "1.0"
5353
dirs-next = "2.0"
5454

5555
# find parent process / watch process
56-
sysinfo = { version = "0.30", default-features = false }
56+
sysinfo = { version = "0.35", default-features = false, features = ["system"] }
5757

5858
# doctor
5959
tinyjson = "2.5" # Small JSON library; used to avoid including a bigger like serde-json

jetsocat/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ impl CommonArgs {
468468
// Find current process' parent process ID
469469
let current_pid =
470470
sysinfo::get_current_pid().map_err(|e| anyhow::anyhow!("couldn't find current process ID: {e}"))?;
471-
let refresh_kind = RefreshKind::new().with_processes(ProcessRefreshKind::new());
472-
let system = System::new_with_specifics(refresh_kind);
473-
let current_process = system.process(current_pid).expect("current process exists");
471+
let mut sys = System::new();
472+
sys.refresh_processes(sysinfo::ProcessesToUpdate::Some(&[current_pid]), false);
473+
let current_process = sys.process(current_pid).expect("current process exists");
474474
Some(current_process.parent().context("couldn't find parent process")?)
475475
} else {
476476
None

jetsocat/src/process_watcher.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
use sysinfo::{Pid, ProcessRefreshKind, RefreshKind, System};
2-
use tokio::time::{sleep, Duration};
1+
use std::process::ExitStatus;
2+
use sysinfo::{Pid, ProcessesToUpdate, System};
3+
use tokio::task;
34

4-
pub(crate) async fn watch_process(pid: Pid) {
5-
let mut system = System::new_with_specifics(RefreshKind::new());
6-
let process_refresh_kind = ProcessRefreshKind::new();
7-
8-
loop {
9-
if !system.refresh_process_specifics(pid, process_refresh_kind) {
10-
return;
11-
}
12-
13-
sleep(Duration::from_secs(60)).await;
14-
}
5+
pub(crate) async fn watch_process(pid: Pid) -> Option<ExitStatus> {
6+
task::spawn_blocking(move || {
7+
let mut sys = System::new();
8+
sys.refresh_processes(ProcessesToUpdate::Some(&[pid]), false);
9+
sys.process(pid).and_then(|p| p.wait())
10+
})
11+
.await
12+
.expect("blocking task panicked")
1513
}

0 commit comments

Comments
 (0)