[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-XBoard] Infinite recursion
From: |
Byrial Jensen |
Subject: |
Re: [Bug-XBoard] Infinite recursion |
Date: |
Fri, 13 Apr 2012 14:57:05 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120411 Thunderbird/11.0.1 |
Den 12-04-2012 16:19, Byrial Jensen skrev:
Den 12-04-2012 11:54, h.g. muller skrev:
If Xboard is dependent on untranslated error messages from libc, it
should run the engines in the C locale. It can be done by calling
putenv("LANGUAGE=C") in the child proces before the exec() call.
It is not that simple. One would want the engines to run in the same
locale as XBoard, in order to get translation of the engine-defined
options in the Engine Settings dialogs. The libc messages that are
recognized by XBoard are supposed to come from intermediaries like
ssh, which you typically use when you run the engines on a remote
machine (using -firstHost, -secondHost). This is needed because such
interediaries might not exit when they fail to execute the engine
binary. The engine itself, when run locally, can inform XBoard of its
failure to start by simply quitting. Failure to exectute the engine
is announced by XBoard to itself (i.e. from the child process to the
main process through the pipe) using perror(), which presumably would
use the current locale. So perhaps we should make the child switch to
the C locale after exec failure, before using perror(). Is that
possible?
Yes it is possible to change locale at any time. In order to force
gettext to notice the change, you can use the this code according to
the gettext manual:
extern int _nl_msg_cat_cntr;
++_nl_msg_cat_cntr;
However if exec fails, or if the child cannot change to the engine
directory, it could just send some recognizable code which an engine
never would use, followed by the localized perror() message.
How about this patch or something similar to make a better detection of
engine startup error?
diff --git a/backend.c b/backend.c
index a2ff648..a80bf38 100644
--- a/backend.c
+++ b/backend.c
@@ -8536,16 +8536,10 @@ if(appData.debugMode) fprintf(debugFP, "nodes =
%d, %lld\n", (int) programStats.
* If chess program startup fails, exit with an error message.
* Attempts to recover here are futile. [HGM] Well, we try anyway
*/
- if ((StrStr(message, "unknown host") != NULL)
- || (StrStr(message, "No remote directory") != NULL)
- || (StrStr(message, "not found") != NULL)
- || (StrStr(message, "No such file") != NULL)
- || (StrStr(message, "can't alloc") != NULL)
- || (StrStr(message, "Permission denied") != NULL)) {
-
+ if (strncmp(message, "XBoard StartChildProcess error:",
strlen("XBoard StartChildProcess error:")) == 0) {
cps->maybeThinking = FALSE;
snprintf(buf1, sizeof(buf1), _("Failed to start %s chess program
%s on %s: %s\n"),
- _(cps->which), cps->program, cps->host, message);
+ _(cps->which), cps->program, cps->host, message +
strlen("XBoard StartChildProcess error:"));
RemoveInputSource(cps->isr);
if(appData.icsActive) DisplayFatalError(buf1, 0, 1); else {
if(LoadError(oldError ? NULL : buf1, cps)) return; // error
has then been handled by LoadError
diff --git a/usystem.c b/usystem.c
index a24d04f..fb35ad2 100644
--- a/usystem.c
+++ b/usystem.c
@@ -465,6 +465,7 @@ StartChildProcess (char *cmdLine, char *dir, ProcRef
*pr)
dup2(1, fileno(stderr)); /* force stderr to the pipe */
if (dir[0] != NULLCHAR && chdir(dir) != 0) {
+ fputs("XBoard StartChildProcess error:", stdout);
perror(dir);
exit(1);
}
@@ -474,6 +475,7 @@ StartChildProcess (char *cmdLine, char *dir, ProcRef
*pr)
execvp(argv[0], argv);
/* If we get here, exec failed */
+ fputs("XBoard StartChildProcess error:", stdout);
perror(argv[0]);
exit(1);
}