Refrain from killing known protocol adapters
authorH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 18 Jun 2019 09:05:10 +0000 (11:05 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 18 Jun 2019 09:05:10 +0000 (11:05 +0200)
Killing 'engines' that run through an adapter and won't terminate fast
enough for XBoard's taste will always be very detrimental, as it will
kill the adapter, and leaves the actual engine (for which the adapter
was likely waiting) running, preventing the adapter would take action
against it. We will thus always refrain from killing engines when XBoard
knows they are running through an adapter, because it invoked the adapter
itself in response to the -f/sUCI option.

backend.c

index ba9b49b..f43d1e9 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -789,7 +789,7 @@ UnloadEngine (ChessProgramState *cps)
            ExitAnalyzeMode();
             DoSleep( appData.delayBeforeQuit );
            SendToProgram("quit\n", cps);
-           DestroyChildProcess(cps->pr, 4 + cps->useSigterm);
+           DestroyChildProcess(cps->pr, 4*!cps->isUCI + cps->useSigterm);
        }
        cps->pr = NoProc;
        if(appData.debugMode) fprintf(debugFP, "Unload %s\n", cps->which);
@@ -12089,7 +12089,7 @@ GameEnds (ChessMove result, char *resultDetails, int whosays)
            ExitAnalyzeMode();
             DoSleep( appData.delayBeforeQuit );
            SendToProgram("quit\n", &first);
-           DestroyChildProcess(first.pr, 4 + first.useSigterm);
+           DestroyChildProcess(first.pr, 4*!first.isUCI + first.useSigterm);
            first.reload = TRUE;
        }
        first.pr = NoProc;
@@ -12114,7 +12114,7 @@ GameEnds (ChessMove result, char *resultDetails, int whosays)
        if (second.pr != NoProc) {
             DoSleep( appData.delayBeforeQuit );
            SendToProgram("quit\n", &second);
-           DestroyChildProcess(second.pr, 4 + second.useSigterm);
+           DestroyChildProcess(second.pr, 4*!second.isUCI + second.useSigterm);
            second.reload = TRUE;
        }
        second.pr = NoProc;
@@ -14769,12 +14769,12 @@ ExitEvent (int status)
 
         DoSleep( appData.delayBeforeQuit );
        SendToProgram("quit\n", &first);
-       DestroyChildProcess(first.pr, 4 + first.useSigterm /* [AS] first.useSigterm */ );
+       DestroyChildProcess(first.pr, 4*!first.isUCI + first.useSigterm /* [AS] first.useSigterm */ );
     }
     if (second.pr != NoProc) {
         DoSleep( appData.delayBeforeQuit );
        SendToProgram("quit\n", &second);
-       DestroyChildProcess(second.pr, 4 + second.useSigterm /* [AS] second.useSigterm */ );
+       DestroyChildProcess(second.pr, 4*!second.isUCI + second.useSigterm /* [AS] second.useSigterm */ );
     }
     if (first.isr != NULL) {
        RemoveInputSource(first.isr);