This commit is contained in:
Albert Armea 2026-02-07 16:51:17 -05:00
parent 9da95a27b3
commit 02ba2965d5
2 changed files with 12 additions and 16 deletions

View file

@ -154,10 +154,9 @@ impl LinuxHost {
for session in &steam_snapshot { for session in &steam_snapshot {
let has_game = !find_steam_game_pids(session.app_id).is_empty(); let has_game = !find_steam_game_pids(session.app_id).is_empty();
if has_game { if has_game {
if let Some(mut map) = steam_sessions.lock().ok() { if let Ok(mut map) = steam_sessions.lock() {
if let Some(entry) = map.get_mut(&session.pid) { map.entry(session.pid)
entry.seen_game = true; .and_modify(|entry| entry.seen_game = true);
}
} }
} else if session.seen_game { } else if session.seen_game {
ended.push((session.pid, session.pgid)); ended.push((session.pid, session.pgid));
@ -356,10 +355,8 @@ impl HostAdapter for LinuxHost {
info!(snap = %snap, "Sent SIGTERM via snap cgroup"); info!(snap = %snap, "Sent SIGTERM via snap cgroup");
} else if let Some(app_id) = info.steam_app_id { } else if let Some(app_id) = info.steam_app_id {
let _ = kill_steam_game_processes(app_id, nix::sys::signal::Signal::SIGTERM); let _ = kill_steam_game_processes(app_id, nix::sys::signal::Signal::SIGTERM);
if let Some(mut map) = self.steam_sessions.lock().ok() { if let Ok(mut map) = self.steam_sessions.lock() {
if let Some(entry) = map.get_mut(&pid) { map.entry(pid).and_modify(|entry| entry.seen_game = true);
entry.seen_game = true;
}
} }
info!(steam_app_id = app_id, "Sent SIGTERM to Steam game processes"); info!(steam_app_id = app_id, "Sent SIGTERM to Steam game processes");
} else if let Some(ref app_id) = info.flatpak_app_id { } else if let Some(ref app_id) = info.flatpak_app_id {
@ -437,10 +434,8 @@ impl HostAdapter for LinuxHost {
info!(snap = %snap, "Sent SIGKILL via snap cgroup"); info!(snap = %snap, "Sent SIGKILL via snap cgroup");
} else if let Some(app_id) = info.steam_app_id { } else if let Some(app_id) = info.steam_app_id {
let _ = kill_steam_game_processes(app_id, nix::sys::signal::Signal::SIGKILL); let _ = kill_steam_game_processes(app_id, nix::sys::signal::Signal::SIGKILL);
if let Some(mut map) = self.steam_sessions.lock().ok() { if let Ok(mut map) = self.steam_sessions.lock() {
if let Some(entry) = map.get_mut(&pid) { map.entry(pid).and_modify(|entry| entry.seen_game = true);
entry.seen_game = true;
}
} }
info!(steam_app_id = app_id, "Sent SIGKILL to Steam game processes"); info!(steam_app_id = app_id, "Sent SIGKILL to Steam game processes");
} else if let Some(ref app_id) = info.flatpak_app_id { } else if let Some(ref app_id) = info.flatpak_app_id {

View file

@ -180,10 +180,11 @@ pub fn find_steam_game_pids(app_id: u32) -> Vec<i32> {
}; };
for key in &keys { for key in &keys {
let prefix = format!("{}=", key); let prefix = format!("{}=", key);
if let Some(val) = var_str.strip_prefix(&prefix) { if var_str
if val == target { .strip_prefix(&prefix)
pids.push(pid); .is_some_and(|val| val == target)
} {
pids.push(pid);
} }
} }
} }