diff options
author | Shauren <shauren.trinity@gmail.com> | 2016-03-21 17:25:34 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2016-03-21 17:25:34 +0100 |
commit | e3af42e05cdf9e4c959d4e038349008da4faca27 (patch) | |
tree | 8fd6ae40a6b4896955157ed79bfbee98e8ae91a2 /src/common/Utilities/Util.cpp | |
parent | 60e1b50b3bc69809cccc6b94fb53c59913512be4 (diff) |
Core/Util: Extracted GetPID to separate function
Diffstat (limited to 'src/common/Utilities/Util.cpp')
-rw-r--r-- | src/common/Utilities/Util.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 5e36bfeb3b7..25bd935de92 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -219,22 +219,29 @@ bool IsIPAddress(char const* ipaddress) } /// create PID file -uint32 CreatePIDFile(const std::string& filename) +uint32 CreatePIDFile(std::string const& filename) { - FILE* pid_file = fopen (filename.c_str(), "w" ); + FILE* pid_file = fopen(filename.c_str(), "w"); if (pid_file == NULL) return 0; + uint32 pid = GetPID(); + + fprintf(pid_file, "%u", pid); + fclose(pid_file); + + return pid; +} + +uint32 GetPID() +{ #ifdef _WIN32 DWORD pid = GetCurrentProcessId(); #else pid_t pid = getpid(); #endif - fprintf(pid_file, "%u", pid ); - fclose(pid_file); - - return (uint32)pid; + return uint32(pid); } size_t utf8length(std::string& utf8str) |