diff --git a/CHANGELOG.md b/CHANGELOG.md index c95c680f..50d3f41a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed +- Fixed the process status detection treating a process as dead when the user + doesn't have permissions to access the child process's memory. This fixes a + seemingly very rare regression from yabridge 3.4.0 where the Wine plugin host + application would immediately be seen as dead when using AppArmor, preventing + yabridge from starting. - Fixed a regression from yabridge 3.4.0 where plugins with zero audio channels like FrozenPlain **Obelisk** would result in a crash. - Fixed a regression from yabridge 3.4.0 where JUCE-based VST3 plugins might diff --git a/src/common/utils.cpp b/src/common/utils.cpp index edc0ed36..3f6870a3 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -85,11 +85,16 @@ 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. - try { - fs::canonical("/proc/" + std::to_string(pid) + "/exe"); - return true; - } catch (const fs::filesystem_error&) { + // 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; } }