Do not nice nice-aware adapters
authorH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 17 Jun 2019 11:55:52 +0000 (13:55 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 17 Jun 2019 11:55:52 +0000 (13:55 +0200)
It is the engine process we want to run at lower priority, not the
adapter it is running through. So if we know the engine is running
through an adapter, because we invoked it ourselves due to -f/sUCI,
and we pass the adapter the value of the -niceEngines option (presumably
for it to set the priority of the engine it forks off by itself),
we refrain from nicing it.

backend.c

index 47b426d..a3220c2 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -11176,13 +11176,15 @@ void
 StartChessProgram (ChessProgramState *cps)
 {
     char buf[MSG_SIZ];
-    int err;
+    int err, priority = appData.niceEngines;
 
     if (appData.noChessProgram) return;
     cps->initDone = FALSE;
 
+    if(cps->isUCI && strstr(appData.adapterCommand, "%niceEngines")) priority = 0; // no nicing on nice adapters!
+
     if (strcmp(cps->host, "localhost") == 0) {
-       err = StartChildProcess(cps->program, cps->dir, &cps->pr, appData.niceEngines);
+       err = StartChildProcess(cps->program, cps->dir, &cps->pr, priority);
     } else if (*appData.remoteShell == NULLCHAR) {
        err = OpenRcmd(cps->host, appData.remoteUser, cps->program, &cps->pr);
     } else {
@@ -11193,7 +11195,7 @@ StartChessProgram (ChessProgramState *cps)
          snprintf(buf, sizeof(buf), "%s %s -l %s %s", appData.remoteShell,
                    cps->host, appData.remoteUser, cps->program);
        }
-       err = StartChildProcess(buf, "", &cps->pr, appData.niceEngines);
+       err = StartChildProcess(buf, "", &cps->pr, priority);
     }
 
     if (err != 0) {