MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CreatePidFile

Function CreatePidFile

src/init.cpp:204–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204[[nodiscard]] static bool CreatePidFile(const ArgsManager& args)
205{
206 if (args.IsArgNegated("-pid")) return true;
207
208 std::ofstream file{GetPidFile(args).std_path()};
209 if (file) {
210#ifdef WIN32
211 tfm::format(file, "%d\n", GetCurrentProcessId());
212#else
213 tfm::format(file, "%d\n", getpid());
214#endif
215 g_generated_pid = true;
216 return true;
217 } else {
218 return InitError(strprintf(_("Unable to create the PID file '%s': %s"), fs::PathToString(GetPidFile(args)), SysErrorString(errno)));
219 }
220}
221
222static void RemovePidFile(const ArgsManager& args)
223{

Callers 1

AppInitMainFunction · 0.85

Calls 7

GetPidFileFunction · 0.85
InitErrorFunction · 0.85
_Function · 0.85
PathToStringFunction · 0.85
SysErrorStringFunction · 0.85
IsArgNegatedMethod · 0.80
formatFunction · 0.70

Tested by

no test coverage detected