From 65ce077940bc5916b7c67fde1856b112ba38de39 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Mon, 25 May 2026 06:36:03 +0200 Subject: Makes data client terminate nicely when signal is received --- data/client.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'data') diff --git a/data/client.cpp b/data/client.cpp index 74f2bc5..f0ffa6a 100644 --- a/data/client.cpp +++ b/data/client.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -368,6 +369,13 @@ void gui_print(void) { // ---------------------------------------------------------------------------- // Main functions // ---------------------------------------------------------------------------- +void sig_handler(int signo) { + (void)signo; + + log_warn("Signal received, will stop SALIS data client..."); + glfwSetWindowShouldClose(g_window, GLFW_TRUE); +} + void glfw_error_callback(int error, const char* description) { log_warn("GLFW error %d: %s", error, description); } @@ -454,6 +462,9 @@ int main(int argc, char **argv) { (void)argc; (void)argv; + signal(SIGINT, sig_handler); + signal(SIGTERM, sig_handler); + log_info("Starting SALIS data client"); log_info("Initializing GLFW"); -- cgit v1.3