Skip to content

Commit

Permalink
Check whether gnubg has crashed or is simply timing out.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanballs committed Jul 13, 2020
1 parent 02bcdff commit 11da87e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion source/ai/gnubg.d
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,18 @@ PipMovement[] gnubgGetTurn(GameState gs, GnubgEvalContext context) {
foreach (i; 0..500) {
if (exists(tmpSock)) break;
Thread.sleep(10.msecs);

if (tryWait(process.pid).terminated == true) {
throw new Exception("Gnubg appears to have crashed. This shouldn't happen.");
}
}

if (!exists(tmpSock)) {
throw new Exception("Could not start gnubg. Can you start it on the command line?");
if (tryWait(process.pid).terminated == true) {
throw new Exception("Gnubg appears to have crashed. This shouldn't happen.");
} else {
throw new Exception("Started gnubg but it doesn't appear to be responding");
}
}

auto c = new Connection(tmpSock);
Expand Down

0 comments on commit 11da87e

Please sign in to comment.