Gracefully stop applications on server quit

This doesn't work with Ctrl+C as the entire process group is signaled,
but it works with wivrnctl stop-server.
This commit is contained in:
Sapphire
2026-08-24 14:13:07 -05:00
parent e604848409
commit c564436377
3 changed files with 59 additions and 30 deletions
+4 -1
View File
@@ -253,6 +253,9 @@ void start_server(configuration config)
}
else if (server_pid == 0)
{
if (do_fork)
setsid();
setenv("AMD_DEBUG", "lowlatencyenc", false);
// https://github.com/WiVRn/WiVRn/issues/695
@@ -316,7 +319,7 @@ void kill_server()
wivrn_ipc_socket_main_loop->send(to_monado::stop{});
// Send SIGTERM after 1s if it is still running
server_kill_watch = g_timeout_add(1000, [](void *) {
server_kill_watch = g_timeout_add(3500, [](void *) {
assert(server_pid > 0);
kill(-server_pid, SIGTERM);
return G_SOURCE_REMOVE; }, 0);