Add UnloadEngine routine
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 18 Apr 2011 13:46:12 +0000 (15:46 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Wed, 20 Apr 2011 20:35:15 +0000 (22:35 +0200)
backend.c

index fcc611a..07897c8 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -692,6 +692,24 @@ CommonEngineInit()
     }
 }
 
+void
+UnloadEngine(ChessProgramState *cps)
+{
+       /* Kill off first chess program */
+       if (cps->isr != NULL)
+         RemoveInputSource(cps->isr);
+       cps->isr = NULL;
+
+       if (cps->pr != NoProc) {
+           ExitAnalyzeMode();
+            DoSleep( appData.delayBeforeQuit );
+           SendToProgram("quit\n", cps);
+            DoSleep( appData.delayAfterQuit );
+           DestroyChildProcess(cps->pr, cps->useSigterm);
+       }
+       cps->pr = NoProc;
+}
+
 void
 ClearOptions(ChessProgramState *cps)
 {