Distinguish between active group hosts and zombies

This commit is contained in:
Robbert van der Helm
2020-06-20 16:58:43 +02:00
parent 61cde0bd43
commit d86b57681b
2 changed files with 13 additions and 2 deletions
+11 -2
View File
@@ -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/<pid>/{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() {