DroidFish: Nicer shutdown of external engines.

Give the engine a chance to shutdown cleanly before killing it by force.
This fixes occasional "text file busy" problems when switching between
two engines.
This commit is contained in:
Peter Osterlund 2017-11-28 19:38:01 +01:00
parent 6277419793
commit 817fbe471a

View File

@ -288,8 +288,17 @@ public class ExternalEngine extends UCIEngineBase {
if (exitThread != null)
exitThread.interrupt();
super.shutDown();
if (engineProc != null)
if (engineProc != null) {
for (int i = 0; i < 25; i++) {
try {
engineProc.exitValue();
break;
} catch (IllegalThreadStateException e) {
try { Thread.sleep(10); } catch (InterruptedException e2) { }
}
}
engineProc.destroy();
}
engineProc = null;
if (stdInThread != null)
stdInThread.interrupt();