mirror of https://github.com/Icinga/icinga2.git
Added Utility::GetPid() helper function.
This commit is contained in:
parent
d98ceb7b79
commit
852ad5d964
|
@ -347,13 +347,7 @@ void Application::UpdatePidFile(const String& filename)
|
|||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifndef _WIN32
|
||||
pid_t pid = getpid();
|
||||
#else /* _WIN32 */
|
||||
DWORD pid = GetCurrentProcessId();
|
||||
#endif /* _WIN32 */
|
||||
|
||||
fprintf(m_PidFile, "%d", pid);
|
||||
fprintf(m_PidFile, "%d", Utility::GetPid());
|
||||
fflush(m_PidFile);
|
||||
}
|
||||
|
||||
|
|
|
@ -289,3 +289,17 @@ double Utility::GetTime(void)
|
|||
return tv.tv_sec + tv.tv_usec / 1000000.0;
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the current process.
|
||||
*
|
||||
* @returns The PID.
|
||||
*/
|
||||
pid_t Utility::GetPid(void)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
return getpid();
|
||||
#else /* _WIN32 */
|
||||
return GetCurrentProcessId();
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ public:
|
|||
|
||||
static double GetTime(void);
|
||||
|
||||
static pid_t GetPid(void);
|
||||
|
||||
private:
|
||||
static bool m_SSLInitialized;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#endif /* __MINGW32__ */
|
||||
|
||||
typedef int socklen_t;
|
||||
typedef DWORD pid_t;
|
||||
|
||||
#define MAXPATHLEN MAX_PATH
|
||||
|
||||
|
|
Loading…
Reference in New Issue