diff options
| author | Martin Ridgers <[email protected]> | 2021-11-09 16:51:14 +0100 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-11-09 16:51:14 +0100 |
| commit | e5bb1ab2b2ebcafaea8888c325d2ad7052de919f (patch) | |
| tree | 25bc09865018e9e29b0576ea3efa82b2e1b29dfe /zencore/thread.cpp | |
| parent | Implemented ProcessHandle::Initialize(Pid) for Linux (diff) | |
| download | zen-e5bb1ab2b2ebcafaea8888c325d2ad7052de919f.tar.xz zen-e5bb1ab2b2ebcafaea8888c325d2ad7052de919f.zip | |
Implemented ProcessHandle::IsRunning() for Linux
Diffstat (limited to 'zencore/thread.cpp')
| -rw-r--r-- | zencore/thread.cpp | 13 |
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 |