mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 12:10:09 +02:00
Fix regression in pid_running from d99f571
In some cases we would treat dead processes as not running (we could also get EAVAIL instead of EINVAL, so it's better to just check the one thing we should treat as a success instead).
This commit is contained in:
@@ -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/<pid>/{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) {
|
||||
|
||||
Reference in New Issue
Block a user