Skip to content

exec: enforce timeout when a child keeps output pipes open - #39

Merged
archlemon merged 1 commit into
mainfrom
fix/exec-waitdelay
Nov 14, 2026
Merged

archlemon merged 1 commit into
mainfrom
fix/exec-waitdelay

Conversation

@archlemon

Copy link
Copy Markdown
Member

Fixes #35.

  • cmd.WaitDelay = 1s: after the command exits or is killed by the context, output pipes are force-closed within 1s instead of waiting for every grandchild.
  • exec.ErrWaitDelay with a successful exit status counts as success (command exited 0 but left a background process holding stdout).
  • Orphaned grandchildren are not killed (would need per-OS process groups); noty just stops waiting on them.

Tests (both took 10s and failed before, ~1s now): sleep 10; echo done with 200ms timeout errors promptly; sleep 10 & echo started succeeds promptly.

CommandContext kills only the direct child on timeout; CombinedOutput
then kept waiting for the output pipe, which any background grandchild
holds, so `sh -c "sleep 20; echo done"` ignored --timeout and
`sh -c "daemon &"` never returned. Set WaitDelay so pipes are closed
shortly after exit or kill, and treat ErrWaitDelay after a successful
exit as success.

Fixes #35
@archlemon archlemon added the bug Something isn't working label Nov 14, 2026
@archlemon
archlemon merged commit d743bbe into main Nov 14, 2026
2 checks passed
@archlemon
archlemon deleted the fix/exec-waitdelay branch November 14, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

exec: --timeout not enforced when a child process keeps stdout open

1 participant