|
|
@ -74,32 +74,11 @@ void HandleSIGTERM(int) |
|
|
|
#ifndef GUI |
|
|
|
#ifndef GUI |
|
|
|
int main(int argc, char* argv[]) |
|
|
|
int main(int argc, char* argv[]) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (int i = 1; i < argc; i++) |
|
|
|
bool fRet = false; |
|
|
|
if (!IsSwitchChar(argv[i][0])) |
|
|
|
fRet = AppInit(argc, argv); |
|
|
|
fCommandLine = true; |
|
|
|
|
|
|
|
fDaemon = !fCommandLine; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __WXGTK__ |
|
|
|
|
|
|
|
if (!fCommandLine) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Daemonize
|
|
|
|
|
|
|
|
pid_t pid = fork(); |
|
|
|
|
|
|
|
if (pid < 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno); |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (pid > 0) |
|
|
|
|
|
|
|
pthread_exit((void*)0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!AppInit(argc, argv)) |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!fShutdown) |
|
|
|
if (fRet && fDaemon) |
|
|
|
Sleep(1000000); |
|
|
|
pthread_exit((void*)0); |
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -113,7 +92,7 @@ bool AppInit(int argc, char* argv[]) |
|
|
|
catch (std::exception& e) { |
|
|
|
catch (std::exception& e) { |
|
|
|
PrintException(&e, "AppInit()"); |
|
|
|
PrintException(&e, "AppInit()"); |
|
|
|
} catch (...) { |
|
|
|
} catch (...) { |
|
|
|
PrintException(NULL, "AppInit()"); |
|
|
|
PrintException(NULL, "AppInit()"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!fRet) |
|
|
|
if (!fRet) |
|
|
|
Shutdown(NULL); |
|
|
|
Shutdown(NULL); |
|
|
@ -213,6 +192,18 @@ bool AppInit2(int argc, char* argv[]) |
|
|
|
|
|
|
|
|
|
|
|
fDebug = GetBoolArg("-debug"); |
|
|
|
fDebug = GetBoolArg("-debug"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fDaemon = GetBoolArg("-daemon"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fDaemon) |
|
|
|
|
|
|
|
fServer = true; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
fServer = GetBoolArg("-server"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* force fServer when running without GUI */ |
|
|
|
|
|
|
|
#ifndef GUI |
|
|
|
|
|
|
|
fServer = true; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
fPrintToConsole = GetBoolArg("-printtoconsole"); |
|
|
|
fPrintToConsole = GetBoolArg("-printtoconsole"); |
|
|
|
fPrintToDebugger = GetBoolArg("-printtodebugger"); |
|
|
|
fPrintToDebugger = GetBoolArg("-printtodebugger"); |
|
|
|
|
|
|
|
|
|
|
@ -220,12 +211,31 @@ bool AppInit2(int argc, char* argv[]) |
|
|
|
|
|
|
|
|
|
|
|
fNoListen = GetBoolArg("-nolisten"); |
|
|
|
fNoListen = GetBoolArg("-nolisten"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < argc; i++) |
|
|
|
|
|
|
|
if (!IsSwitchChar(argv[i][0])) |
|
|
|
|
|
|
|
fCommandLine = true; |
|
|
|
|
|
|
|
|
|
|
|
if (fCommandLine) |
|
|
|
if (fCommandLine) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int ret = CommandLineRPC(argc, argv); |
|
|
|
int ret = CommandLineRPC(argc, argv); |
|
|
|
exit(ret); |
|
|
|
exit(ret); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GUI |
|
|
|
|
|
|
|
if (fDaemon) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Daemonize
|
|
|
|
|
|
|
|
pid_t pid = fork(); |
|
|
|
|
|
|
|
if (pid < 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (pid > 0) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
if (!fDebug && !pszSetDataDir[0]) |
|
|
|
if (!fDebug && !pszSetDataDir[0]) |
|
|
|
ShrinkDebugFile(); |
|
|
|
ShrinkDebugFile(); |
|
|
|
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); |
|
|
|
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); |
|
|
@ -443,7 +453,7 @@ bool AppInit2(int argc, char* argv[]) |
|
|
|
if (!CreateThread(StartNode, NULL)) |
|
|
|
if (!CreateThread(StartNode, NULL)) |
|
|
|
wxMessageBox("Error: CreateThread(StartNode) failed", "Bitcoin"); |
|
|
|
wxMessageBox("Error: CreateThread(StartNode) failed", "Bitcoin"); |
|
|
|
|
|
|
|
|
|
|
|
if (GetBoolArg("-server") || fDaemon) |
|
|
|
if (fServer) |
|
|
|
CreateThread(ThreadRPCServer, NULL); |
|
|
|
CreateThread(ThreadRPCServer, NULL); |
|
|
|
|
|
|
|
|
|
|
|
#if defined(__WXMSW__) && defined(GUI) |
|
|
|
#if defined(__WXMSW__) && defined(GUI) |
|
|
|