summaryrefslogtreecommitdiffstats
path: root/src/sdk/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdk/main.cpp')
-rw-r--r--src/sdk/main.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/sdk/main.cpp b/src/sdk/main.cpp
index 78d24ea70..70c675f91 100644
--- a/src/sdk/main.cpp
+++ b/src/sdk/main.cpp
@@ -44,7 +44,7 @@
#include <iostream>
-#if defined(Q_OS_OSX)
+#if defined(Q_OS_OSX) or defined(Q_OS_UNIX)
# include <unistd.h>
# include <sys/types.h>
#endif
@@ -133,8 +133,24 @@ int main(int argc, char *argv[])
const bool production = (mode.compare(QLatin1String(QInstaller::Protocol::ModeProduction),
Qt::CaseInsensitive) == 0);
- if (production)
+ if (production) {
argumentsValid = (!key.isEmpty()) && (!socketName.isEmpty());
+#if defined(Q_OS_UNIX) && !defined(Q_OS_OSX)
+ /* In production mode detach child so that sudo waiting on us will terminate. */
+ pid_t child = fork();
+ if (child <= -1) {
+ std::cerr << "Fatal cannot fork and detach server." << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ if (child != 0) {
+ return EXIT_SUCCESS;
+ }
+
+ ::setsid();
+#endif
+ }
+
SDKApp<QCoreApplication> app(argc, argv);
if (!argumentsValid) {