diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-09-20 10:56:25 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-09-20 11:03:59 +0200 |
commit | d6712db35419e36b2c89191eb730a86d95abf4b0 (patch) | |
tree | 2f251c16c9b9689aaef24f0012378d410c005591 /src/init.cpp | |
parent | 25308337d659108e3320257fb6c1c16d5fe24aa9 (diff) |
Also create pid file in non-daemon mode
Always make a pid file, not only when `-daemon` specified.
This is useful for troubleshooting, for attaching debuggers and loggers
and such.
- Write the pid file only after the datadir lock was acquired
- Don't create or remove a pid file on WIN32, and also don't show the option
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/init.cpp b/src/init.cpp index 67f53e044c..7299bd0f4a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -160,7 +160,9 @@ void Shutdown() if (pwalletMain) bitdb.Flush(true); #endif +#ifndef WIN32 boost::filesystem::remove(GetPidFile()); +#endif UnregisterAllWallets(); #ifdef ENABLE_WALLET if (pwalletMain) @@ -228,7 +230,9 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += " -maxorphanblocks=<n> " + strprintf(_("Keep at most <n> unconnectable blocks in memory (default: %u)"), DEFAULT_MAX_ORPHAN_BLOCKS) + "\n"; strUsage += " -maxorphantx=<n> " + strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS) + "\n"; strUsage += " -par=<n> " + strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"), -(int)boost::thread::hardware_concurrency(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS) + "\n"; +#ifndef WIN32 strUsage += " -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n"; +#endif strUsage += " -reindex " + _("Rebuild block chain index from current blk000??.dat files") + " " + _("on startup") + "\n"; #if !defined(WIN32) strUsage += " -sysperms " + _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)") + "\n"; @@ -714,7 +718,9 @@ bool AppInit2(boost::thread_group& threadGroup) static boost::interprocess::file_lock lock(pathLockFile.string().c_str()); if (!lock.try_lock()) return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin Core is probably already running."), strDataDir)); - +#ifndef WIN32 + CreatePidFile(GetPidFile(), getpid()); +#endif if (GetBoolArg("-shrinkdebugfile", !fDebug)) ShrinkDebugFile(); LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); |