From 781f2658510eb33b8e61eb29c46c3635c91b0076 Mon Sep 17 00:00:00 2001 From: pager Date: Mon, 8 Dec 2025 15:27:37 -0500 Subject: [PATCH] patch monado to respect terminate signals Although it doesn't terminate properly with this it seems to make `systemctl --user restart monado` work --- 0001-ipc-shutdown-ipc-server-on-SIGTERM.patch | 68 +++++++++++++++++++ vr-overlay.nix | 4 +- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 0001-ipc-shutdown-ipc-server-on-SIGTERM.patch diff --git a/0001-ipc-shutdown-ipc-server-on-SIGTERM.patch b/0001-ipc-shutdown-ipc-server-on-SIGTERM.patch new file mode 100644 index 0000000..a0c991f --- /dev/null +++ b/0001-ipc-shutdown-ipc-server-on-SIGTERM.patch @@ -0,0 +1,68 @@ +From 8d75be68315bec605a95b50edf7d2a6c56772b7f Mon Sep 17 00:00:00 2001 +From: Sapphire +Date: Tue, 25 Nov 2025 23:20:46 -0600 +Subject: [PATCH] ipc: shutdown ipc server on SIGTERM + +--- + src/xrt/ipc/server/ipc_server_process.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/src/xrt/ipc/server/ipc_server_process.c b/src/xrt/ipc/server/ipc_server_process.c +index 92c232904..47a4a70bc 100644 +--- a/src/xrt/ipc/server/ipc_server_process.c ++++ b/src/xrt/ipc/server/ipc_server_process.c +@@ -50,6 +50,10 @@ + #include + #endif + ++#if defined(XRT_OS_UNIX) ++#include ++#endif ++ + + /* + * +@@ -1062,6 +1066,16 @@ ipc_server_get_system_properties(struct ipc_server *vs, struct xrt_system_proper + return XRT_SUCCESS; + } + ++#ifdef XRT_OS_UNIX ++struct ipc_server *g_server; ++static void handle_signal(int signal) ++{ ++ if (g_server && signal == SIGTERM) { ++ ipc_server_handle_shutdown_signal(g_server); ++ } ++} ++#endif ++ + int + ipc_server_main_common(const struct ipc_server_main_info *ismi, + const struct ipc_server_callbacks *callbacks, +@@ -1086,6 +1100,11 @@ ipc_server_main_common(const struct ipc_server_main_info *ismi, + timeBeginPeriod(1); + #endif + ++#ifdef XRT_OS_UNIX ++ g_server = s; ++ signal(SIGTERM, handle_signal); ++#endif ++ + /* + * Need to create early before any vars are added. Not created in + * init_all since that function is shared with Android and the debug +@@ -1127,6 +1146,11 @@ ipc_server_main_common(const struct ipc_server_main_info *ismi, + // Stop the UI before tearing everything down. + u_debug_gui_stop(&s->debug_gui); + ++#ifdef XRT_OS_UNIX ++ signal(SIGTERM, NULL); ++ g_server = NULL; ++#endif ++ + // Done after UI stopped. + teardown_all(s); + free(s); +-- +2.52.0 + diff --git a/vr-overlay.nix b/vr-overlay.nix index 0d6bfe9..9596388 100644 --- a/vr-overlay.nix +++ b/vr-overlay.nix @@ -25,7 +25,9 @@ rev = "2ebbca83e896e0802185277ce0a0a463db7a7892"; hash = "sha256-JjlKHXd1SD9M8OpgFERZCvAhM0eMxjME96YU38DlKNw="; }; - patches = []; + patches = [ + ./0001-ipc-shutdown-ipc-server-on-SIGTERM.patch + ]; }); }) ];