diff --git a/rehlds/dedicated/src/sys_linux.cpp b/rehlds/dedicated/src/sys_linux.cpp index 111d652..5a0cf11 100644 --- a/rehlds/dedicated/src/sys_linux.cpp +++ b/rehlds/dedicated/src/sys_linux.cpp @@ -314,8 +314,21 @@ char* BuildCmdLine(int argc, char **argv) return linuxCmdline; } +static void ConsoleCtrlHandler(int signal) +{ + if (signal == SIGINT || signal == SIGTERM) + { + g_bAppHasBeenTerminated = true; + } +} + bool Sys_SetupConsole() { + struct sigaction action; + action.sa_handler = ConsoleCtrlHandler; + sigaction(SIGINT, &action, NULL); + sigaction(SIGTERM, &action, NULL); + return true; } @@ -327,7 +340,6 @@ int main(int argc, char *argv[]) { Q_snprintf(g_szEXEName, sizeof(g_szEXEName), "%s", argv[0]); char* cmdline = BuildCmdLine(argc, argv); - StartServer(cmdline); - return 0; + return StartServer(cmdline) == LAUNCHER_OK ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index 373e4e8..e6e2bf9 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -1212,7 +1212,12 @@ void Host_Shutdown(void) if (host_initialized) // Client-side Host_WriteConfiguration(); +#ifdef REHLDS_FIXES + Host_ShutdownServer(FALSE); +#else SV_ServerShutdown(); +#endif + Voice_Deinit(); host_initialized = FALSE;