From b178edea533e74b68d0d1a303be98d5454256887 Mon Sep 17 00:00:00 2001 From: untodesu Date: Sat, 22 Mar 2025 16:37:53 +0500 Subject: Handle termination signals on client-side --- game/client/main.cc | 9 +++++++++ game/server/pch.hh | 2 -- game/shared/pch.hh | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'game') diff --git a/game/client/main.cc b/game/client/main.cc index 277b278..86e9783 100644 --- a/game/client/main.cc +++ b/game/client/main.cc @@ -127,6 +127,12 @@ static void GLAD_API_PTR on_opengl_message(GLenum source, GLenum type, GLuint id spdlog::info("opengl: {}", reinterpret_cast(message)); } +static void on_termination_signal(int) +{ + spdlog::warn("client: received termination signal"); + glfwSetWindowShouldClose(globals::window, true); +} + int main(int argc, char **argv) { cmdline::create(argc, argv); @@ -178,6 +184,9 @@ int main(int argc, char **argv) std::terminate(); } + std::signal(SIGINT, &on_termination_signal); + std::signal(SIGTERM, &on_termination_signal); + glfwMakeContextCurrent(globals::window); glfwSwapInterval(1); diff --git a/game/server/pch.hh b/game/server/pch.hh index 5a4f5f2..89b396b 100644 --- a/game/server/pch.hh +++ b/game/server/pch.hh @@ -4,6 +4,4 @@ #include -#include - #endif /* SERVER_PCH_HH */ diff --git a/game/shared/pch.hh b/game/shared/pch.hh index 3588709..1776f9b 100644 --- a/game/shared/pch.hh +++ b/game/shared/pch.hh @@ -4,6 +4,8 @@ #include +#include + #include #include -- cgit