MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / stop_game_process

Method stop_game_process

modules/mcp/mcp_server.cpp:217–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217Error MCPServer::stop_game_process() {
218 OS::ProcessID pid_to_kill = 0;
219 {
220 MutexLock lock(process_mutex);
221 if (game_pid == 0) {
222 return ERR_DOES_NOT_EXIST;
223 }
224 pid_to_kill = game_pid;
225 }
226
227 Error err = OS::get_singleton()->kill(pid_to_kill);
228 if (err == OK) {
229 // Wait up to 1s for it to exit and be reaped
230 uint64_t start = OS::get_singleton()->get_ticks_msec();
231 while (OS::get_singleton()->is_process_running(pid_to_kill) && OS::get_singleton()->get_ticks_msec() - start < 1000) {
232 OS::get_singleton()->delay_usec(10000);
233 }
234 MutexLock lock(process_mutex);
235 if (game_pid == pid_to_kill) {
236 game_pid = 0;
237 }
238 }
239 return err;
240}
241
242bool MCPServer::is_game_running() const {
243 MutexLock lock(process_mutex);

Callers 1

tool_project_configMethod · 0.80

Calls 4

killMethod · 0.45
get_ticks_msecMethod · 0.45
is_process_runningMethod · 0.45
delay_usecMethod · 0.45

Tested by

no test coverage detected