Treat EACCES for pid_running() as alive

When the user has some sort of hardening going on, we might not be able
to read the Wine process's memory. In that case this check would return
`false` even though the process is still running. To combat this, we
should explicitly check for `EINVAL` which is returned when the file
doesn't exist at all or when it's a broken 'symlink' (even though it
isn't really a symlink).
This commit is contained in:
Robbert van der Helm
2021-07-18 14:49:57 +02:00
parent 4fc683188b
commit d99f571c05
2 changed files with 14 additions and 4 deletions
+5
View File
@@ -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
+9 -4
View File
@@ -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/<pid>/{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;
}
}