diff options
| author | Martin Ridgers <[email protected]> | 2022-01-07 14:23:32 +0100 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2022-01-07 14:23:32 +0100 |
| commit | 54d0185e39bab7c388749b08368db94201c2ea8d (patch) | |
| tree | 8ff416465b111d6240ae1a53ec4fc76e25d1fe5a /zencore/thread.cpp | |
| parent | Use Zen's Invocable to cover C++ libs that do not implement concepts (diff) | |
| download | zen-54d0185e39bab7c388749b08368db94201c2ea8d.tar.xz zen-54d0185e39bab7c388749b08368db94201c2ea8d.zip | |
Use null-signal kill() to determine if a PID is valid
Diffstat (limited to 'zencore/thread.cpp')
| -rw-r--r-- | zencore/thread.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/zencore/thread.cpp b/zencore/thread.cpp index f01cba7a8..c710930a6 100644 --- a/zencore/thread.cpp +++ b/zencore/thread.cpp @@ -650,9 +650,7 @@ ProcessHandle::IsRunning() const 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); + bActive = (kill(pid_t(m_Pid), 0) == 0); #else # error Check process control on this platform #endif @@ -1130,13 +1128,8 @@ IsProcessRunning(int pid) CloseHandle(hProc); return true; -#elif ZEN_PLATFORM_LINUX - char Buffer[64]; - sprintf(Buffer, "/proc/%d", pid); - return access(Buffer, F_OK) == 0; -#elif ZEN_PLATFORM_MAC - kill(pid_t(pid), 0); - return errno != ESRCH; +#elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC + return (kill(pid_t(pid), 0) == 0); #endif } |