aboutsummaryrefslogtreecommitdiff
path: root/init.cpp
diff options
context:
space:
mode:
authortcatm <[email protected]>2011-03-21 12:11:05 +0100
committertcatm <[email protected]>2011-03-21 12:11:05 +0100
commit1c09a4adb20aed76dd5f07051c605ffd56a093d6 (patch)
treeb52dc23cdedd6dd744e31876df6287f2d964d38a /init.cpp
parentUpdate copyright in About box from 2010 to 2011 (diff)
downloaddiscoin-1c09a4adb20aed76dd5f07051c605ffd56a093d6.tar.xz
discoin-1c09a4adb20aed76dd5f07051c605ffd56a093d6.zip
daemon-mode: add sleep() loop to prevent defunct child process, call setsid() in child
Diffstat (limited to 'init.cpp')
-rw-r--r--init.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/init.cpp b/init.cpp
index 8e5812669..c0b03c877 100644
--- a/init.cpp
+++ b/init.cpp
@@ -236,6 +236,10 @@ bool AppInit2(int argc, char* argv[])
}
if (pid > 0)
return true;
+
+ pid_t sid = setsid();
+ if (sid < 0)
+ fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
}
#endif
@@ -466,6 +470,10 @@ bool AppInit2(int argc, char* argv[])
if (fFirstRun)
SetStartOnSystemStartup(true);
#endif
+
+ if (fDaemon)
+ while (!fShutdown)
+ Sleep(5000);
return true;
}