Skip to content

Commit 5a2fd23

Browse files
fix Steam stop function, it can get into an infinite loop (#431)
* fix Steam stop function, it can get into an infinite loop * add log * skip process stop if not able to send the quit/kill signals Ont the Steam Deck, it will try to kill the steamos-manager process, which is owned by root.
1 parent 85d5077 commit 5a2fd23

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/steam/restarter.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,32 @@ pub fn ensure_steam_stopped() {
1414
let processes = s.processes_by_name(os_steam_name);
1515
for process in processes {
1616
let mut s = System::new();
17-
process.kill_with(sysinfo::Signal::Quit);
18-
process.kill_with(sysinfo::Signal::Kill);
17+
18+
let quit_res = process.kill_with(sysinfo::Signal::Quit);
19+
let kill_res = process.kill_with(sysinfo::Signal::Kill);
20+
21+
if quit_res == Some(false) && kill_res == Some(false) {
22+
// Couldn't kill the process, this could be because it was already killed or we don't have permissions
23+
// For instance, the process "steamos-manager" in the Steam Deck is owned by root
24+
continue;
25+
}
26+
1927
let pid = process.pid();
28+
let process_name = process.name();
2029
let pid_arr = [pid];
2130
let process_to_update = ProcessesToUpdate::Some(&pid_arr);
22-
while s.refresh_processes_specifics(process_to_update, true,ProcessRefreshKind::everything()) == 0{
23-
println!("Waiting for steam to stop");
31+
32+
while s.refresh_processes_specifics(process_to_update, true,ProcessRefreshKind::everything()) > 0
33+
// The process is still alive
34+
&& s.process(pid).is_some()
35+
{
36+
println!("Waiting for steam to stop. PID: {pid:?} Name: {process_name:?}");
2437
sleep(Duration::from_millis(500));
2538
process.kill_with(sysinfo::Signal::Quit);
2639
process.kill_with(sysinfo::Signal::Kill);
2740
}
2841
}
42+
println!("Steam is stopped");
2943
}
3044
#[cfg(target_os = "windows")]
3145
pub fn ensure_steam_started(settings: &super::SteamSettings) {

0 commit comments

Comments
 (0)