From: H.G.Muller Date: Mon, 5 Dec 2016 08:29:13 +0000 (+0100) Subject: Display error message when engine dies X-Git-Tag: v4.0~43 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=f26559fcc563015f7049626337121d1b448bfee5;p=uci2wb.git Display error message when engine dies UCI2WB used to exit silently when reading from the engine produced an EOF response (indicating the engine process died). This then evoked the standard XBoard fatal error "... engine exited uexpectedly". Now it sends a 'tellusererror' command to the GUI to suppress the standard popup, and to clearly indicate that it was because of a crash in the engine rather than in the adapter. --- diff --git a/UCI2WB.c b/UCI2WB.c index 9b5e70c..f094d10 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -41,7 +41,7 @@ #define NONE 2 #define ANALYZE 3 -char move[2000][10], iniPos[256], hashOpt[20], pause, pondering, suspended, ponder, post, hasHash, c, sc='c', suffix[81], *variants, varOpt, searching; +char move[2000][10], iniPos[256], hashOpt[20], pause, pondering, suspended, ponder, post, hasHash, c, sc='c', suffix[81], *variants, varOpt, searching, *binary; int mps, tc, inc, sTime, depth, myTime, hisTime, stm, computer = NONE, memory, oldMem=0, cores, moveNr, lastDepth, lastScore, startTime, debug, flob; int statDepth, statScore, statNodes, statTime, currNr, size, collect, nr, sm, inex, on[500], frc, byo = -1, namOpt, comp; char currMove[20], moveMap[500][10], /* for analyze mode */ canPonder[20], threadOpt[20], varList[8000], anaOpt[20], backLog[10000], checkOptions[8192] = "Ponder"; @@ -264,7 +264,7 @@ Engine2GUI() fflush(stdout); fflush(toE); while((line[i] = x = GetChar()) != EOF && line[i] != '\n') i++; line[++i] = 0; - if(x == EOF) exit(0); + if(x == EOF) printf("tellusererror UCI2WB: %s died on me\n", binary), exit(0); DPRINT("# engine said: %s", line), fflush(stdout); if(sscanf(line, "%s", command) != 1) continue; if(!strcmp(command, "bestmove")) { @@ -691,7 +691,7 @@ main(int argc, char **argv) else if(sc == 'n') sc = 'c'; // UCI for normal Chess // spawn engine proc - if(StartEngine(argv[1], dir) != NO_ERROR) { perror(argv[1]), exit(-1); } + if(StartEngine(binary = argv[1], dir) != NO_ERROR) { perror(argv[1]), exit(-1); } Sync(INIT);