From e5bb1ab2b2ebcafaea8888c325d2ad7052de919f Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Tue, 9 Nov 2021 16:51:14 +0100 Subject: Implemented ProcessHandle::IsRunning() for Linux --- zencore/thread.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'zencore/thread.cpp') diff --git a/zencore/thread.cpp b/zencore/thread.cpp index 5c6658b35..3cb126d87 100644 --- a/zencore/thread.cpp +++ b/zencore/thread.cpp @@ -344,10 +344,21 @@ ProcessHandle::Initialize(int Pid) bool ProcessHandle::IsRunning() const { + bool bActive = false; + +#if ZEN_PLATFORM_WINDOWS DWORD ExitCode = 0; GetExitCodeProcess(m_ProcessHandle, &ExitCode); + bActive = (ExitCode == STILL_ACTIVE); +#elif ZEN_PLATFORM_LINUX + StringBuilder<64> ProcPath; + ProcPath << "/proc/" << m_Pid; + bActive = (access(ProcPath.c_str(), F_OK) != 0); +#else +# error Check process control on this platform +#endif - return ExitCode == STILL_ACTIVE; + return bActive; } bool -- cgit v1.2.3