diff --git a/Userland/Games/Chess/Engine.cpp b/Userland/Games/Chess/Engine.cpp index cfe7502482..d436dd5005 100644 --- a/Userland/Games/Chess/Engine.cpp +++ b/Userland/Games/Chess/Engine.cpp @@ -7,6 +7,7 @@ #include "Engine.h" #include +#include #include #include #include @@ -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()); diff --git a/Userland/Services/ChessEngine/main.cpp b/Userland/Services/ChessEngine/main.cpp index 81975d2feb..c12fce6efd 100644 --- a/Userland/Services/ChessEngine/main.cpp +++ b/Userland/Services/ChessEngine/main.cpp @@ -16,7 +16,11 @@ ErrorOr 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); };