summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-03-22 16:37:53 +0500
committeruntodesu <kirill@untode.su>2025-03-22 16:37:53 +0500
commitb178edea533e74b68d0d1a303be98d5454256887 (patch)
tree3f76966664889af6df18722661cbff479589d6ba
parentde5abf13da7e2a7663929da9d76be2161e574b64 (diff)
downloadvoxelius-b178edea533e74b68d0d1a303be98d5454256887.tar.bz2
voxelius-b178edea533e74b68d0d1a303be98d5454256887.zip
Handle termination signals on client-side
-rw-r--r--game/client/main.cc9
-rw-r--r--game/server/pch.hh2
-rw-r--r--game/shared/pch.hh2
3 files changed, 11 insertions, 2 deletions
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<const char *>(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 <shared/pch.hh>
-#include <csignal>
-
#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 <core/pch.hh>
+#include <csignal>
+
#include <BS_thread_pool.hpp>
#include <enet/enet.h>