Merge pull request #684 from roderickvd/fix-onevent-panic

Log error instead of panicking when child fails to start
This commit is contained in:
Sasha Hilton 2021-05-01 01:18:05 +01:00 committed by GitHub
commit 8973d29837
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -768,15 +768,20 @@ async fn main() {
Some(event) => {
if let Some(program) = &setup.player_event_program {
if let Some(child) = run_program_on_events(event, program) {
let mut child = child.expect("program failed to start");
if child.is_ok() {
tokio::spawn(async move {
match child.wait().await {
Ok(status) if !status.success() => error!("child exited with status {:?}", status.code()),
Err(e) => error!("failed to wait on child process: {}", e),
_ => {}
}
});
let mut child = child.unwrap();
tokio::spawn(async move {
match child.wait().await {
Ok(status) if !status.success() => error!("child exited with status {:?}", status.code()),
Err(e) => error!("failed to wait on child process: {}", e),
_ => {}
}
});
} else {
error!("program failed to start");
}
}
}
},