diff --git a/src/common/utils.cpp b/src/common/utils.cpp index f748166f..ef9aab8b 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -94,17 +94,13 @@ bool pid_running(pid_t pid) { // processes and zombies, and a terminated group host process will always be // left as a zombie process. If the process is active, then // `/proc//{cwd,exe,root}` will be valid symlinks. - // NOTE: We can get a `EACCES` here if we don't have permissions to read - // this process's memory, so we should explicitly check for `EINVAL` - // indicating that the 'symlink' is broken or just does not exist at - // all. boost::system::error_code err; fs::canonical("/proc/" + std::to_string(pid) + "/exe", err); - if (err && err.value() == EINVAL) { - return false; - } else { - return true; - } + + // NOTE: We can get a `EACCES` here if we don't have permissions to read + // this process's memory. This does mean that the process is still + // running. + return err.failed() || err.value() == EACCES; } std::string url_encode_path(std::string path) {