aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/main.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2024-08-14 16:20:32 +0200
committerGitHub Enterprise <[email protected]>2024-08-14 16:20:32 +0200
commit92066c19239422e9c09c4ccd46d42fd573ce6853 (patch)
tree26b307053e4b4a3b116a05b46834f35ff38f8d7e /src/zenserver/main.cpp
parentupdated Lucas-C/pre-commit-hooks to v1.3.1 to fix compilation on MacOS (#114) (diff)
downloadzen-92066c19239422e9c09c4ccd46d42fd573ce6853.tar.xz
zen-92066c19239422e9c09c4ccd46d42fd573ce6853.zip
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.
Diffstat (limited to 'src/zenserver/main.cpp')
-rw-r--r--src/zenserver/main.cpp13
1 files changed, 8 insertions, 5 deletions
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)