Hello,
I have just compiled TSCP for Fedora7 and can now play engine-engine match in a crude way, just edit command to :-
xboard -fcp /usr/bin/gnuchess
-scp /home/rasjid/tscp/tscp -tc 1:0 -mps 60
and everthings fine.
My own SnailChess can run without bugs in winboard Windows XP but fails as the second program in xboard fedora7. There is a message "fail to write to second program, broken pipe ...second program exited unexpectedly"
Can someone tell what is the likely problem.
Best Regards,
Rasjid
What is broken pipe in xboard ?
Moderator: Ras
-
- Posts: 588
- Joined: Thu Mar 09, 2006 4:47 pm
- Location: Singapore
-
- Posts: 588
- Joined: Thu Mar 09, 2006 4:47 pm
- Location: Singapore
Re: What is broken pipe in xboard ?
Yes.
Are you flushing stdout?
With winboard+Windows XP compiled with mingw, it plays just normal and never crash or hang.
I suspect it is still my code for linux gcc that has problems. It seems my program exited unexpectedly and thus xboard "fail to write to second chess program, broken pipe" ? may be because my program exited.
Rasjid
Re: What is broken pipe in xboard ?
Did you follow point 7. Signals in the engine-intf.html distributed with xboard?
It applies only to engines running under Unix.
I just do a:
when I receive the xboard command.
It applies only to engines running under Unix.
I just do a:
Code: Select all
signal(SIGINT, SIG_IGN);
Re: What is broken pipe in xboard ?
Yes, it's a consequence of an error, not the error itself.Chan Rasjid wrote:Yes.
Are you flushing stdout?
With winboard+Windows XP compiled with mingw, it plays just normal and never crash or hang.
I suspect it is still my code for linux gcc that has problems. It seems my program exited unexpectedly and thus xboard "fail to write to second chess program, broken pipe" ? may be because my program exited.
Rasjid
Tony
-
- Posts: 588
- Joined: Thu Mar 09, 2006 4:47 pm
- Location: Singapore
Re: What is broken pipe in xboard ?
Yes, I have signal(SIGINT, SIG_IGN);
I have traced the line that gave problems. It is fgets() in the while loop.
In a game with
tscp - w
snail - b
1) tscp makes the 1st move and snail receives "go" and searches and returns a valid move acknowledged by xboard and "make" in the GUI.
2) tscp makes the 2nd move and xboard pipe it to snail through stdin. But fgets(line, 255, stdin) fails !
I don't know much about streams or fedora linux.
Rasjid
I have traced the line that gave problems. It is fgets() in the while loop.
In a game with
tscp - w
snail - b
1) tscp makes the 1st move and snail receives "go" and searches and returns a valid move acknowledged by xboard and "make" in the GUI.
2) tscp makes the 2nd move and xboard pipe it to snail through stdin. But fgets(line, 255, stdin) fails !
I don't know much about streams or fedora linux.
Code: Select all
int main(int argc, char *argv[]) {
setbuf(stdin, NULL);
setbuf(stdout, NULL);
signal(SIGTERM, SIG_IGN);
printf("\n");
...
}
while (1) {
fflush(stdout);
if (side == computerSide) {
int r = callSearch(board, ss, searchinfo, incheck, side, followPV);
if (r != RESULT_NULL) {
gameResult(r, side, *ss->pv);
computerSide = NullSide;
continue;
}
side ^= 1;
continue;
}
ftime(&searchinfo->timeb_start);
printf("telluser fgets \n");
if (!fgets(line, 256, stdin)) {
return;
}
printf("telluser fgets ok\n");
if (line[0] == '\n'){
continue;
}
sscanf(line,"%s",command);
if (!strcmp(command, "xboard")) {
printf("\n");
continue;
}
.....
}/* while loop*/
-
- Posts: 892
- Joined: Sun Nov 19, 2006 9:16 pm
- Location: Russia
Re: What is broken pipe in xboard ?
On success, the function returns the same str parameter.
If the End-of-File is encountered and no characters have been read, the contents of str remain unchanged and a null pointer is returned.
If an error occurs, a null pointer is returned.
Use either ferror or feof to check whether an error happened or the End-of-File was reached.
Re: What is broken pipe in xboard ?
Yeah, unfortunately I've seen that error all to many times. It's invariably because my program crashed (to the surprise of XBoard).Chan Rasjid wrote:Yes.
Are you flushing stdout?
With winboard+Windows XP compiled with mingw, it plays just normal and never crash or hang.
I suspect it is still my code for linux gcc that has problems. It seems my program exited unexpectedly and thus xboard "fail to write to second chess program, broken pipe" ? may be because my program exited.
Rasjid
-
- Posts: 588
- Joined: Thu Mar 09, 2006 4:47 pm
- Location: Singapore
Re: What is broken pipe in xboard ?
I do follow closely as what tscp did but my think() to get a move is fairly elaborate. Don't know why fgets() fails after return from the first think().
The problem is control only reaches A and prints "fgets A" and does not print "fgets B". Just have to sit back a while.
Rasjid
Code: Select all
printf("telluser fgets A\n");
if (!fgets(line, 256, stdin)) {
printf("telluser fgets B\n");
return;
}
printf("telluser fgets C\n");
Rasjid
-
- Posts: 1922
- Joined: Thu Mar 09, 2006 12:51 am
- Location: Earth
Re: What is broken pipe in xboard ?
Are you sure you have SIGINT ignored too? The code you posted only has SIGTERM. You should have both. The error isn't necessarily caused by fgets, because your program will be blocking, waiting for input inside the function, where it could be interrupted.