aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/main.cpp
diff options
context:
space:
mode:
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)