Skip to content

fix(daemon): drain the engine's pseudo-terminal before closing it - #262

Merged
outofcoffee merged 1 commit into
mainfrom
fix/pty-capture-drain
Oct 5, 2026
Merged

outofcoffee merged 1 commit into
mainfrom
fix/pty-capture-drain

Conversation

@outofcoffee

Copy link
Copy Markdown
Collaborator

Summary

  • The supervisor closed the PTY master as soon as the engine exited, discarding the engine's last stdout writes that the pump had not yet read. This is the cause of the intermittent TestSupervisorPTYCapture failures on Linux CI.
  • The exit goroutine now waits for the pump to reach end of stream, and closes the master itself only after ptyDrainTimeout (2s), which covers a child of the engine holding the slave open.

Key changes

  • internal/daemon/supervisor.go: wait for the pump before closing the master, with a timeout.
  • internal/daemon/supervisor_pty_test.go: a test for the lingering-child timeout.
  • docs/maintainer/internals.md: note on why the master is not closed on exit.

Fixes #252

The exit goroutine closed the PTY master as soon as the engine was
reaped, discarding output written just before the exit that the pump had
not yet read. It now waits for the pump to reach end of stream, closing
the master itself only after ptyDrainTimeout (a child of the engine can
hold the slave open).

Fixes #252
@outofcoffee
outofcoffee marked this pull request as ready for review October 5, 2026 22:20
@outofcoffee
outofcoffee merged commit 7d785c4 into main Oct 5, 2026
5 checks passed
@outofcoffee
outofcoffee deleted the fix/pty-capture-drain branch October 5, 2026 22:35
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.

TestSupervisorPTYCapture flakes on ubuntu runners — the capture can lose the engine's last stdout writes

1 participant