Add UnloadEngine routine
[xboard.git] / 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)
 {