From 92066c19239422e9c09c4ccd46d42fd573ce6853 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 14 Aug 2024 16:20:32 +0200 Subject: added `--detach` option to zenserver (#115) added `--detach` option to zenserver. When this is passed in with a false value, we do not create a new process group in order to behave more as expected when running with `xmake run zenserver`. Without this change the zenserver process does not receive any signals and won't exit when xmake does, causing processes to linger in the background. The default behaviour (when run from UE) is unchanged. --- src/zenserver/main.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/zenserver/main.cpp') diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp index c27d4eb04..e6ecc3ce2 100644 --- a/src/zenserver/main.cpp +++ b/src/zenserver/main.cpp @@ -351,11 +351,6 @@ main(int argc, char* argv[]) } } -#if ZEN_PLATFORM_LINUX | ZEN_PLATFORM_MAC - // Detach ourselves from any parent process - setsid(); -#endif - signal(SIGINT, utils::SignalCallbackHandler); signal(SIGTERM, utils::SignalCallbackHandler); @@ -364,6 +359,14 @@ main(int argc, char* argv[]) ZenServerOptions ServerOptions; ParseCliOptions(argc, argv, ServerOptions); + if (ServerOptions.Detach) + { +#if ZEN_PLATFORM_LINUX | ZEN_PLATFORM_MAC + // Detach ourselves from any parent process + setsid(); +#endif + } + std::string_view DeleteReason; if (ServerOptions.IsCleanStart) -- cgit v1.2.3