mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:17:34 +00:00
Chess+ChessEngine: Fix stockfish by setting correct blocking flag
Stockfish apparently cannot handle non-blocking I/O, and it does not make sense to assume that all chess engines can do so. Fixes #18946.
This commit is contained in:
parent
62ebb78433
commit
bdeccf8844
2 changed files with 10 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "Engine.h"
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <fcntl.h>
|
||||
#include <spawn.h>
|
||||
#include <stdio.h>
|
||||
|
@ -27,12 +28,12 @@ void Engine::connect_to_engine_service()
|
|||
{
|
||||
int wpipefds[2];
|
||||
int rpipefds[2];
|
||||
if (pipe2(wpipefds, O_CLOEXEC | O_NONBLOCK) < 0) {
|
||||
if (pipe2(wpipefds, O_CLOEXEC) < 0) {
|
||||
perror("pipe2");
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
if (pipe2(rpipefds, O_CLOEXEC | O_NONBLOCK) < 0) {
|
||||
if (pipe2(rpipefds, O_CLOEXEC) < 0) {
|
||||
perror("pipe2");
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -55,9 +56,11 @@ void Engine::connect_to_engine_service()
|
|||
close(rpipefds[1]);
|
||||
|
||||
auto infile = Core::File::adopt_fd(rpipefds[0], Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
|
||||
infile->set_blocking(false).release_value_but_fixme_should_propagate_errors();
|
||||
set_in(move(infile)).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
auto outfile = Core::File::adopt_fd(wpipefds[1], Core::File::OpenMode::Write).release_value_but_fixme_should_propagate_errors();
|
||||
outfile->set_blocking(false).release_value_but_fixme_should_propagate_errors();
|
||||
set_out(move(outfile));
|
||||
|
||||
send_command(Chess::UCI::UCICommand());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue