diff --git a/src/util.cpp b/src/util.cpp index 9342b8f..f0f5a81 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1113,6 +1113,7 @@ boost::filesystem::path GetPidFile() return pathPidFile; } +#ifdef WIN32 void CreatePidFile(const boost::filesystem::path &path, util_pid_t pid) { FILE* file = fopen(path.string().c_str(), "w"); @@ -1122,6 +1123,17 @@ void CreatePidFile(const boost::filesystem::path &path, util_pid_t pid) fclose(file); } } +#else +void CreatePidFile(const boost::filesystem::path &path, pid_t pid) +{ + FILE* file = fopen(path.string().c_str(), "w"); + if (file) + { + fprintf(file, "%d\n", pid); + fclose(file); + } +} +#endif bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest) { diff --git a/src/util.h b/src/util.h index c05972b..c88dfcd 100644 --- a/src/util.h +++ b/src/util.h @@ -7,6 +7,10 @@ #include "uint256.h" +#include +#include +#include + #ifndef WIN32 #include #include @@ -15,9 +19,6 @@ #include typedef int util_pid_t; /* define for Windows compatibility */ #endif -#include -#include -#include #include #include @@ -217,7 +218,11 @@ boost::filesystem::path GetDefaultDataDir(); const boost::filesystem::path &GetDataDir(bool fNetSpecific = true); boost::filesystem::path GetConfigFile(); boost::filesystem::path GetPidFile(); +#ifdef WIN32 void CreatePidFile(const boost::filesystem::path &path, util_pid_t pid); +#else +void CreatePidFile(const boost::filesystem::path &path, pid_t pid); +#endif void ReadConfigFile(std::map& mapSettingsRet, std::map >& mapMultiSettingsRet); #ifdef WIN32 boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);