1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:27:45 +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:
Ben Wiederhake 2023-05-21 22:27:01 +02:00 committed by Andreas Kling
parent 62ebb78433
commit bdeccf8844
2 changed files with 10 additions and 3 deletions

View file

@ -16,7 +16,11 @@ ErrorOr<int> serenity_main(Main::Arguments)
Core::EventLoop loop;
TRY(Core::System::unveil(nullptr, nullptr));
auto engine = TRY(ChessEngine::try_create(TRY(Core::File::standard_input()), TRY(Core::File::standard_output())));
auto infile = TRY(Core::File::standard_input());
TRY(infile->set_blocking(false));
auto outfile = TRY(Core::File::standard_output());
TRY(outfile->set_blocking(false));
auto engine = TRY(ChessEngine::try_create(move(infile), move(outfile)));
engine->on_quit = [&](auto status_code) {
loop.quit(status_code);
};