computerd: killExec/timeout leave the real command running, and post-exit output is buffered unbounded, burying the exit event
Runner.exec spawns /bin/sh -c "cd <cwd> && <cmd>" and kill() / the timeout signal only child.pid. On Debian, /bin/sh is dash with patch 0004, which disables the sh -c exec optimisation. So <cmd> is a grandchild and survives SIGKILL; the same happens on any image for pipelines and & jobs.
After the shell exits, Node's ChildProcess onexit calls flushStdio(), which resume()s stdout and stderr. LiveSubscriber.pause() returns early because paused is still true, and enqueue() ignores desiredSize. Until exitDrainMaxMs (5 s) every chunk the surviving writer produces is queued in memory; we measured 13.7 GB in 5 s with yes. The exit event is queued behind it, so a client reading at network speed never sees it. The writer keeps running after finalise (flowStdio drops its output).
Repro: exec("yes"), read slowly, killExec(id, "SIGKILL") → no exit event for minutes; the container keeps an orphaned yes.
Suggested fixes:
- Spawn with
detached: trueand signal the process group (process.kill(-pid, sig)) inkill(), the timeout anddisposeRecord. - Re-pause the pipes on every over-HWM enqueue rather than relying on the flag. Or, once the child has exited, stop enqueueing past the HWM and finalise when the deadline fires.
Seen on computerd 0.10.0 (ghcr.io/cloudflare/computer-computerd-linux-x64:0.10.0, debian:stable-slim base) with @cloudflare/computer 0.10.0 / LegacyContainerBackend.
I've opened a fix: https://github.com/cloudflare/computer/pull/312
- Cause: the exec's shell wasn't in its own process group, so kill/timeout/dispose missed grandchildren; and
pause()returned early on its flag after Node resumed the pipes on exit, so output was buffered unbounded ahead of the exit event. - Change: spawn detached and signal the process group;
pause()always re-pauses the pipes. The test suite could not be run in my environment, so the fix is untested by execution.