Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix game processes being in a zombie state when exiting #33

Merged
merged 4 commits into from
Aug 19, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
},
};

#[cfg(all(unix, feature = "auto-splitting"))]
#[cfg(unix)]
use std::thread;
Refragg marked this conversation as resolved.
Show resolved Hide resolved

#[cfg(feature = "auto-splitting")]
mod auto_splitters;
mod ffi;
Expand Down Expand Up @@ -618,9 +622,31 @@
if state.game_path.exists() {
info!("Starting game...");

let mut process = Command::new(state.game_path.clone());

Check failure on line 625 in src/lib.rs

View workflow job for this annotation

GitHub Actions / format

Diff in /home/runner/work/obs-livesplit-one/obs-livesplit-one/src/lib.rs

process.spawn().ok();
let child = process.spawn().ok();

Check warning on line 627 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build (Windows aarch64)

unused variable: `child`

Check warning on line 627 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build (Windows i686)

unused variable: `child`

Check warning on line 627 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build (Windows x86_64)

unused variable: `child`

Check warning on line 627 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build (Windows x86_64-v3)

unused variable: `child`

#[cfg(unix)]
{
// For Unix systems only, spawn a new thread that waits for the process to exit.
// This avoids keeping the process in a zombie state and never letting go of it until
// the plugin is unloaded
thread::spawn(move || {

Check failure on line 634 in src/lib.rs

View workflow job for this annotation

GitHub Actions / format

Diff in /home/runner/work/obs-livesplit-one/obs-livesplit-one/src/lib.rs

Check failure on line 634 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build (Linux arm Hardware Float)

failed to resolve: use of undeclared crate or module `thread`

Check failure on line 634 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build (Linux armv7 Hardware Float)

failed to resolve: use of undeclared crate or module `thread`

Check failure on line 634 in src/lib.rs

View workflow job for this annotation

GitHub Actions / build (Linux i686)

failed to resolve: use of undeclared crate or module `thread`
if child.is_none() {
warn!("Failure starting the game process");
return;
};
Refragg marked this conversation as resolved.
Show resolved Hide resolved

let exit_status = child.unwrap().wait();
if let Err(e) = exit_status {
warn!("Failure waiting for the game process' exit: {e}");
return;

Check failure on line 643 in src/lib.rs

View workflow job for this annotation

GitHub Actions / format

Diff in /home/runner/work/obs-livesplit-one/obs-livesplit-one/src/lib.rs
};

info!("Game process exited with {}", exit_status.unwrap())
Refragg marked this conversation as resolved.
Show resolved Hide resolved
});
}

Check failure on line 649 in src/lib.rs

View workflow job for this annotation

GitHub Actions / format

Diff in /home/runner/work/obs-livesplit-one/obs-livesplit-one/src/lib.rs
return false;
}

Expand Down
Loading