Registry Mirror
Skip to content

Conversation

@KR-Ravindra

Copy link
Copy Markdown

Problem

A command that leaves a descendant holding stdout/stderr (tool &, a daemon) keeps cmd.Wait() in reap() blocked for the descendant's lifetime, because Start() passes non-*os.File writers and sets no WaitDelay. The exec stays RUNNING and pins two log files, two pipes and a MaxConcurrentProcesses slot, so a long-lived sandbox eventually hits ENFILE or ErrTooManyProcesses.

Fixes #136

Fix

Set cmd.WaitDelay to 1s in Start(). Once the command itself exits, Wait() gives the copiers 1s to drain, then closes the pipes and returns exec.ErrWaitDelay; reap() already ignores that error and reads the exit status from cmd.ProcessState. Output written before exit is still captured.

How tested

TestBackgroundChildDoesNotBlockExit (echo hi; sleep 30 &) takes 30s on main and ~1s with the change; go test ./guest/process, make verify-gofmt verify-boilerplate clean.

Experimented and verified with an AI agent.

Signed-off-by: KR Ravindra <42912207+KR-Ravindra@users.noreply.github.com>
@KR-Ravindra
KR Ravindra (KR-Ravindra) marked this pull request as ready for review December 2, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

guest process tracker: Wait() never returns when a command leaves a background process holding stdout/stderr, leaking fds and process slots until ENFILE

1 participant