mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-08 22:34:30 +02:00
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 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#ifndef _WIN32
|
fprintf(m_PidFile, "%d", Utility::GetPid());
|
||||||
pid_t pid = getpid();
|
|
||||||
#else /* _WIN32 */
|
|
||||||
DWORD pid = GetCurrentProcessId();
|
|
||||||
#endif /* _WIN32 */
|
|
||||||
|
|
||||||
fprintf(m_PidFile, "%d", pid);
|
|
||||||
fflush(m_PidFile);
|
fflush(m_PidFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,3 +289,17 @@ double Utility::GetTime(void)
|
|||||||
return tv.tv_sec + tv.tv_usec / 1000000.0;
|
return tv.tv_sec + tv.tv_usec / 1000000.0;
|
||||||
#endif /* _WIN32 */
|
#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 double GetTime(void);
|
||||||
|
|
||||||
|
static pid_t GetPid(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool m_SSLInitialized;
|
static bool m_SSLInitialized;
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#endif /* __MINGW32__ */
|
#endif /* __MINGW32__ */
|
||||||
|
|
||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
|
typedef DWORD pid_t;
|
||||||
|
|
||||||
#define MAXPATHLEN MAX_PATH
|
#define MAXPATHLEN MAX_PATH
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user