mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Move all PID file stuff to init.cpp
It is only used from init.cpp. Move-only refactoring.
This commit is contained in:
38
src/init.cpp
38
src/init.cpp
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user