fix: close the VBS-side gaps noted on Void/Library#61
VoidBuildSystem CI / sanitizers-gcc16 (push) Failing after 7s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 13s
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 5s
VoidBuildSystem CI / wine-windows-gcc16 (push) Failing after 57s

This commit is contained in:
faumaray committed 2026-12-05 10:30:57 +03:00
1 parent 4f581d1b51
commit 4d51331777
13 files changed
+158 -14

No files matched your search

+28 -3
View File
@@ -158,8 +158,11 @@ run_supervised(const ProcessRequest &request, std::stop_token stop) {
// drains, times out, or is cancelled, then escalate via SIGTERM -> kill_grace -> SIGKILL.
bool group_timed_out = comm->timed_out;
bool group_cancelled = comm->cancelled;
bool descendants_terminated = false;
const pid_t pgid = static_cast<pid_t>(child->pgid());
if (!group_timed_out && !group_cancelled && !comm->overflowed) {
const auto descendant_deadline =
std::chrono::steady_clock::now() + request.descendant_grace;
while (child->process_group_alive()) {
// Reap any adopted descendants in this process group (subreaper) so zombies clear.
int wstatus = 0;
@@ -172,18 +175,40 @@ run_supervised(const ProcessRequest &request, std::stop_token stop) {
group_cancelled = true;
break;
}
if (has_timeout && std::chrono::steady_clock::now() >= deadline) {
const auto now = std::chrono::steady_clock::now();
if (has_timeout && now >= deadline) {
group_timed_out = true;
break;
}
// Orphans must not keep the supervisor (or a test run) alive forever.
if (request.descendant_grace.count() > 0 && now >= descendant_deadline) {
descendants_terminated = true;
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds{10});
}
}
if (group_cancelled || group_timed_out || comm->overflowed || child->process_group_alive()) {
if (group_cancelled || group_timed_out || descendants_terminated || comm->overflowed ||
child->process_group_alive()) {
(void)child->terminate(request.kill_grace);
// Reap the whole group until it is really gone (bounded), so no zombie or orphan is
// left behind after test supervision.
const auto reap_deadline =
std::chrono::steady_clock::now() + request.kill_grace + std::chrono::seconds{2};
int wstatus = 0;
while (pgid > 0 && ::waitpid(-pgid, &wstatus, WNOHANG) > 0) {
while (pgid > 0) {
const pid_t reaped = ::waitpid(-pgid, &wstatus, WNOHANG);
if (reaped < 0) { // ECHILD: no descendants left.
break;
}
if (reaped == 0) {
if (std::chrono::steady_clock::now() >= reap_deadline) {
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds{5});
continue;
}
}
}