From 98663031ca7e8ea2fcbf5a0cad96577724de83c2 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Sat, 28 Nov 2026 04:45:49 -0500 Subject: [PATCH] fix(handoff): a wait that finds no child rechecks live handoffs --- tools/nativeguest/hook/handoff.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/nativeguest/hook/handoff.c b/tools/nativeguest/hook/handoff.c index f09ae81284..37b4a709b9 100644 --- a/tools/nativeguest/hook/handoff.c +++ b/tools/nativeguest/hook/handoff.c @@ -1491,6 +1491,13 @@ static pid_t ddh_wait(pid_t pid, int *status, int options, struct rusage *ru) { if (status) *status = wstatus; return r; } + // No child left: a handoff may have claimed its entry since the look above, and another + // waiter reaped its forked child. The program still runs, so this wait goes on. + if (!live && r < 0 && errno == ECHILD) { + struct ddh_entry *c = pid > 0 ? ddh_find(pid) : NULL; + live = pid > 0 ? (c && ddh_selects(c, pid)) || ddh_claiming(pid) : ddh_any_live(pid); + errno = ECHILD; + } if (!live) return r; if (r < 0 && errno != ECHILD) return r; if (options & WNOHANG) return 0;