1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

Chess: Send a quit command to ChessEngine when it is no longer in use

The chess GUI now instructs the ChessEngine to gracefully exit by
sending a UCI quit command.
This commit is contained in:
Tim Ledbetter 2023-04-01 23:23:43 +01:00 committed by Sam Atkins
parent c2b9376409
commit bf320e4826
2 changed files with 8 additions and 3 deletions

View file

@ -13,8 +13,7 @@
Engine::~Engine()
{
if (m_pid != -1)
kill(m_pid, SIGINT);
quit();
}
Engine::Engine(StringView command)
@ -66,3 +65,8 @@ void Engine::handle_bestmove(Chess::UCI::BestMoveCommand const& command)
m_bestmove_callback = nullptr;
}
void Engine::quit()
{
send_command(Chess::UCI::QuitCommand());
}

View file

@ -33,6 +33,7 @@ public:
}
private:
void quit();
Function<void(Chess::Move)> m_bestmove_callback;
pid_t m_pid { -1 };
};