proc: magpie serve reaps the processes it adopts (Kling__Lab on X)

254 <defunct> children of `magpie serve` after 7 days, growing ~9 an hour
(magpie, uv, node, npm, magpie-bun, code-review-graph), only a restart
cleared them. Every command magpie starts is waited for (the AST guard
TestEveryStartedCommandIsWaited holds, and I read each Start site and
Output/StartTree/StartReaped by hand: none is missed). The zombies are the
grandchildren: an agent CLI's MCP servers whose parent ended are adopted by
magpie where it is PID 1 (a container) or a child subreaper, and nothing
waits for a process it never started.

proc.KeepReaping (Linux, from serve) does nothing unless magpie adopts
(PID 1 or PR_GET_CHILD_SUBREAPER), and then reaps a child of its own that
was a zombie at two looks 5s apart. Not tried: the reporter's container;
the cause (PID 1 / subreaper) is inferred from the report, not seen.

Run: TestAdoptedOrphansAreReaped (subreaper test process, 6 orphans) and
the proc package through wsl-run on magpie-desktop: ok. Broken by hand
(KeepReaping returning at once): 6 adopted zombies left, red.
This commit is contained in:
yetone
2026-11-13 10:29:07 +08:00
parent 422f90e80b
commit 382c8c0bdf
4 changed files with 205 additions and 0 deletions
+2
View File
@@ -1,6 +1,7 @@
package cli
import (
"context"
"fmt"
"net"
"net/url"
@@ -230,6 +231,7 @@ func serveCmd(args []string) error {
}
}
proc.UserPath() // as magpie web's (#3803)
proc.KeepReaping(context.Background())
if web == "" {
return serve()
}