|
|
@ -9,6 +9,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "chainparams.h" |
|
|
|
#include "chainparams.h" |
|
|
|
#include "clientversion.h" |
|
|
|
#include "clientversion.h" |
|
|
|
|
|
|
|
#include "compat.h" |
|
|
|
#include "rpc/server.h" |
|
|
|
#include "rpc/server.h" |
|
|
|
#include "init.h" |
|
|
|
#include "init.h" |
|
|
|
#include "noui.h" |
|
|
|
#include "noui.h" |
|
|
@ -127,29 +128,21 @@ bool AppInit(int argc, char* argv[]) |
|
|
|
fprintf(stderr, "Error: There is no RPC client functionality in bitcoind anymore. Use the bitcoin-cli utility instead.\n"); |
|
|
|
fprintf(stderr, "Error: There is no RPC client functionality in bitcoind anymore. Use the bitcoin-cli utility instead.\n"); |
|
|
|
exit(1); |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
} |
|
|
|
#ifndef WIN32 |
|
|
|
|
|
|
|
if (GetBoolArg("-daemon", false)) |
|
|
|
if (GetBoolArg("-daemon", false)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#if HAVE_DECL_DAEMON |
|
|
|
fprintf(stdout, "Bitcoin server starting\n"); |
|
|
|
fprintf(stdout, "Bitcoin server starting\n"); |
|
|
|
|
|
|
|
|
|
|
|
// Daemonize
|
|
|
|
// Daemonize
|
|
|
|
pid_t pid = fork(); |
|
|
|
if (daemon(1, 0)) { // don't chdir (1), do close FDs (0)
|
|
|
|
if (pid < 0) |
|
|
|
fprintf(stderr, "Error: daemon() failed: %s\n", strerror(errno)); |
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno); |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (pid > 0) // Parent process, pid is child process id
|
|
|
|
#else |
|
|
|
{ |
|
|
|
fprintf(stderr, "Error: -daemon is not supported on this operating system\n"); |
|
|
|
return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
#endif // HAVE_DECL_DAEMON
|
|
|
|
// Child process falls through to rest of initialization
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pid_t sid = setsid(); |
|
|
|
|
|
|
|
if (sid < 0) |
|
|
|
|
|
|
|
fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
SoftSetBoolArg("-server", true); |
|
|
|
SoftSetBoolArg("-server", true); |
|
|
|
|
|
|
|
|
|
|
|
// Set this early so that parameter interactions go to console
|
|
|
|
// Set this early so that parameter interactions go to console
|
|
|
|