From d86b57681bf8fcdc84aa8ab670003bdb5eeb14b6 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 20 Jun 2020 16:58:43 +0200 Subject: [PATCH] Distinguish between active group hosts and zombies --- CHANGELOG.md | 2 ++ src/plugin/host-process.cpp | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ead32c6..1cc64004 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). - Fixed the Wine prefix being overwritten for all subsequent plugins opened within the same process. This prevented the use of multiple Wine prefixes within hosts that do not sandbox their plugins, such as Ardour. +- Distinguish between active processes and zombies when checking whether a group + host process is still running during initialization. ## [1.2.0] - 2020-05-29 diff --git a/src/plugin/host-process.cpp b/src/plugin/host-process.cpp index f7c1c33e..eb91eed2 100644 --- a/src/plugin/host-process.cpp +++ b/src/plugin/host-process.cpp @@ -234,8 +234,17 @@ bool GroupHost::running() { // process is still running, however Boost.Process does not allow you to do // the same thing for a process that's not a direct child if this process. // When using plugin groups we'll have to manually check whether the PID - // returned by the group host process is still active. - return kill(host_pid, 0) == 0; + // returned by the group host process is still active. We sadly can't use + // `kill()` for this as that provides no way to distinguish between active + // 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(host_pid) + "/exe"); + return true; + } catch (const fs::filesystem_error&) { + return false; + } } void GroupHost::terminate() {