Skip to content

Commit

Permalink
check if starcraft started successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
tatref committed Oct 29, 2018
1 parent 75a4727 commit 01c6286
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,16 @@ impl Instance {
.arg("-windowHeight")
.arg(window.h.to_string());

self.child = Some(cmd.spawn()?);
let mut child = cmd.spawn()?;
std::thread::sleep(std::time::Duration::from_millis(50));
if let Ok(Some(status)) = child.try_wait() {
if !status.success() {
println!("{:?}", child.wait_with_output().unwrap());
bail!(ErrorKind::CantStartExe);
}
}
self.child = Some(child);
//self.child = Some(cmd.spawn()?);

Ok(())
}
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ error_chain! {
description("Executable was not supplied to the coordinator")
display("StarCraft II exe was not specified")
}
/// Executable was not supplied to the coordinator.
CantStartExe {
description("Executable couldn't start")
display("StarCraft II exe couldn't start")
}
/// Executable supplied to the coordinator does not exist.
ExeDoesNotExist(exe: PathBuf) {
description("Executable supplied to the coordinator does not exist")
Expand Down

0 comments on commit 01c6286

Please sign in to comment.