aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortcatm <tcatm@gawab.com>2011-04-08 23:59:32 -0400
committerJeff Garzik <jgarzik@pobox.com>2011-04-08 23:59:32 -0400
commitd12ea887bcf1eab4b029007c4bf5821992c0c6b1 (patch)
treeb12475510f1380ba09132828723852a78137963a
parentd98beea894c82063362011bb7f44a09995fd6047 (diff)
disable -daemon on windows; bitcoind forks only with -daemon set
[added setsid() call to ui.cpp, to regain consistency with init.cpp -jgarzik]
-rw-r--r--init.cpp24
-rw-r--r--ui.cpp4
2 files changed, 20 insertions, 8 deletions
diff --git a/init.cpp b/init.cpp
index 8c70ba2eba..00e64a7a94 100644
--- a/init.cpp
+++ b/init.cpp
@@ -78,7 +78,9 @@ int main(int argc, char* argv[])
fRet = AppInit(argc, argv);
if (fRet && fDaemon)
- pthread_exit((void*)0);
+ return 0;
+
+ return 1;
}
#endif
@@ -160,6 +162,8 @@ bool AppInit2(int argc, char* argv[])
" -paytxfee=<amt> \t " + _("Fee per KB to add to transactions you send\n") +
#ifdef GUI
" -server \t\t " + _("Accept command line and JSON-RPC commands\n") +
+#endif
+#ifndef __WXMSW__
" -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") +
#endif
" -testnet \t\t " + _("Use the test network\n") +
@@ -196,17 +200,20 @@ bool AppInit2(int argc, char* argv[])
fDebug = GetBoolArg("-debug");
+#ifndef __WXMSW__
fDaemon = GetBoolArg("-daemon");
+#else
+ fDaemon = false;
+#endif
if (fDaemon)
fServer = true;
else
fServer = GetBoolArg("-server");
- /* force fServer and fDaemon when running without GUI */
+ /* force fServer when running without GUI */
#ifndef GUI
fServer = true;
- fDaemon = true;
#endif
fPrintToConsole = GetBoolArg("-printtoconsole");
@@ -226,7 +233,7 @@ bool AppInit2(int argc, char* argv[])
exit(ret);
}
-#ifndef GUI
+#ifndef __WXMSW__
if (fDaemon)
{
// Daemonize
@@ -472,10 +479,11 @@ bool AppInit2(int argc, char* argv[])
if (fFirstRun)
SetStartOnSystemStartup(true);
#endif
-
- if (fDaemon)
- while (!fShutdown)
- Sleep(5000);
+
+#ifndef GUI
+ while (1)
+ Sleep(5000);
+#endif
return true;
}
diff --git a/ui.cpp b/ui.cpp
index f4c0c4d749..9ae19e8a6f 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -2808,6 +2808,10 @@ bool CMyApp::Initialize(int& argc, wxChar** argv)
}
if (pid > 0)
pthread_exit((void*)0);
+
+ pid_t sid = setsid();
+ if (sid < 0)
+ fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
}
return true;