aboutsummaryrefslogtreecommitdiff
path: root/zencore/thread.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-11-09 16:51:14 +0100
committerMartin Ridgers <[email protected]>2021-11-09 16:51:14 +0100
commite5bb1ab2b2ebcafaea8888c325d2ad7052de919f (patch)
tree25bc09865018e9e29b0576ea3efa82b2e1b29dfe /zencore/thread.cpp
parentImplemented ProcessHandle::Initialize(Pid) for Linux (diff)
downloadzen-e5bb1ab2b2ebcafaea8888c325d2ad7052de919f.tar.xz
zen-e5bb1ab2b2ebcafaea8888c325d2ad7052de919f.zip
Implemented ProcessHandle::IsRunning() for Linux
Diffstat (limited to 'zencore/thread.cpp')
-rw-r--r--zencore/thread.cpp13
1 files changed, 12 insertions, 1 deletions
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