3c7b6c3d93
* fix(loginpty): drain PTY before close on natural child exit so last bytes aren't lost The supervise loop closed the PTY master immediately after the child exited, racing with readLoop's blocked Read. Go's poller cancels the in-flight Read with "file already closed" and the kernel's buffered bytes are dropped — observed as TestStart_RunsCommandAndExits flaking on CI with `expected 'hello' in output, got ""`. Give readLoop a 500ms grace window to drain naturally (Unix master sees EIO once the slave closes); only force-close if drainage doesn't complete (Windows ConPTY, which never delivers EOF on child exit). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix(loginpty): always close PTY after drain window so the master fd doesn't leak The previous revision only called sess.stop() in the timeout branch of the drain select, so on the Unix happy path (readDone fires first) the PTY master fd stayed open until GC ran the *os.File finalizer. Move stop() outside the select — by the time it runs readLoop has already returned, so there's no in-flight Read to race with — and switch the fallback to time.NewTimer with Stop() to release the timer eagerly when readDone wins. Addresses review feedback from CodeRabbit, Claude, Greptile, and cubic on #1004. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Kandev Agent <agent@kandev.dev> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>