Move all PID file stuff to init.cpp

It is only used from init.cpp.
Move-only refactoring.
This commit is contained in:
Hennadii Stepanov
2019-02-14 22:53:03 +02:00
parent 561e375c73
commit 3782075a5f
3 changed files with 24 additions and 26 deletions

View File

@@ -94,6 +94,30 @@ std::unique_ptr<BanMan> g_banman;
static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
/**
* The PID file facilities.
*/
#ifndef WIN32
static const char* BITCOIN_PID_FILENAME = "bitcoind.pid";
static fs::path GetPidFile()
{
return AbsPathForConfigVal(fs::path(gArgs.GetArg("-pid", BITCOIN_PID_FILENAME)));
}
NODISCARD static bool CreatePidFile()
{
FILE* file = fsbridge::fopen(GetPidFile(), "w");
if (file) {
fprintf(file, "%d\n", getpid());
fclose(file);
return true;
} else {
return InitError(strprintf(_("Unable to create the PID file '%s': %s"), GetPidFile().string(), std::strerror(errno)));
}
}
#endif
//////////////////////////////////////////////////////////////////////////////
//
// Shutdown
@@ -1194,20 +1218,6 @@ bool AppInitLockDataDirectory()
return true;
}
#ifndef WIN32
NODISCARD static bool CreatePidFile()
{
FILE* file = fsbridge::fopen(GetPidFile(), "w");
if (file) {
fprintf(file, "%d\n", getpid());
fclose(file);
return true;
} else {
return InitError(strprintf(_("Unable to create the PID file '%s': %s"), GetPidFile().string(), std::strerror(errno)));
}
}
#endif
bool AppInitMain(InitInterfaces& interfaces)
{
const CChainParams& chainparams = Params();