diff options
author | Tim Ledbetter <timledbetter@gmail.com> | 2023-04-01 23:23:43 +0100 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2023-04-20 09:59:18 +0100 |
commit | bf320e4826ece33b0190332dda3e135786b48c89 (patch) | |
tree | c0d576891818a66e12d4b5ca68fd1f1d848593d0 | |
parent | c2b9376409fe06f8ca3bb03d39a793a3e78c7c1e (diff) | |
download | serenity-bf320e4826ece33b0190332dda3e135786b48c89.zip |
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.
-rw-r--r-- | Userland/Games/Chess/Engine.cpp | 8 | ||||
-rw-r--r-- | Userland/Games/Chess/Engine.h | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/Userland/Games/Chess/Engine.cpp b/Userland/Games/Chess/Engine.cpp index a28b5fc13c..cbfcf40d1d 100644 --- a/Userland/Games/Chess/Engine.cpp +++ b/Userland/Games/Chess/Engine.cpp @@ -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()); +} diff --git a/Userland/Games/Chess/Engine.h b/Userland/Games/Chess/Engine.h index d91127714b..dd5906cf84 100644 --- a/Userland/Games/Chess/Engine.h +++ b/Userland/Games/Chess/Engine.h @@ -33,6 +33,7 @@ public: } private: + void quit(); + Function<void(Chess::Move)> m_bestmove_callback; - pid_t m_pid { -1 }; }; |