Skip to content

Commit

Permalink
Merge remote branch 'tcatm/fix-daemon-mode' into patched
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Corallo committed Apr 2, 2011
2 parents c902d2a + c2f76c3 commit dec20d9
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions init.cpp
Expand Up @@ -77,7 +77,9 @@ int main(int argc, char* argv[])
fRet = AppInit(argc, argv);

if (fRet && fDaemon)
pthread_exit((void*)0);
return 0;

return 1;
}
#endif

Expand Down Expand Up @@ -167,6 +169,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 WIN32
" -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") +
#endif
" -testnet \t\t " + _("Use the test network\n") +
Expand Down Expand Up @@ -203,17 +207,20 @@ bool AppInit2(int argc, char* argv[])

fDebug = GetBoolArg("-debug");

#ifndef WIN32
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");
Expand All @@ -233,7 +240,7 @@ bool AppInit2(int argc, char* argv[])
exit(ret);
}

#ifndef GUI
#ifndef WIN32
if (fDaemon)
{
// Daemonize
Expand Down Expand Up @@ -491,10 +498,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;
}

0 comments on commit dec20d9

Please sign in to comment.