mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17: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:
parent
c2b9376409
commit
bf320e4826
2 changed files with 8 additions and 3 deletions
|
@ -13,8 +13,7 @@
|
||||||
|
|
||||||
Engine::~Engine()
|
Engine::~Engine()
|
||||||
{
|
{
|
||||||
if (m_pid != -1)
|
quit();
|
||||||
kill(m_pid, SIGINT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::Engine(StringView command)
|
Engine::Engine(StringView command)
|
||||||
|
@ -66,3 +65,8 @@ void Engine::handle_bestmove(Chess::UCI::BestMoveCommand const& command)
|
||||||
|
|
||||||
m_bestmove_callback = nullptr;
|
m_bestmove_callback = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::quit()
|
||||||
|
{
|
||||||
|
send_command(Chess::UCI::QuitCommand());
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void quit();
|
||||||
|
|
||||||
Function<void(Chess::Move)> m_bestmove_callback;
|
Function<void(Chess::Move)> m_bestmove_callback;
|
||||||
pid_t m_pid { -1 };
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue