fix: Handle platform specific PTY polling for terminal copy (#279)

* fix: Handle platform specific PTY polling for terminal copy

* fix: Code review fixes

* fix: Code review fixes
This commit is contained in:
Abhisek Datta
2026-05-28 18:11:11 +05:30
committed by GitHub
parent 1c25395d74
commit 4540dafccc
6 changed files with 269 additions and 6 deletions
+10
View File
@@ -21,6 +21,12 @@ type InteractiveSession interface {
// PtyReader returns the reader to receive output from the child process
PtyReader() io.Reader
// CopyOutputContext copies child output to dst until the child exits (EOF)
// or ctx is cancelled. On unix it drives the read with a poll(2) loop so it
// works even when the Go netpoller cannot manage the PTY master, and so it
// can be cancelled without leaking a goroutine blocked in read().
CopyOutputContext(ctx context.Context, dst io.Writer) error
// SetRawMode puts terminal in raw mode (for PTY passthrough)
SetRawMode() error
@@ -129,6 +135,10 @@ func NewSession(ctx context.Context, cfg SessionConfig) (InteractiveSession, err
func (s *session) PtyWriter() io.Writer { return s.spawn.PtyWriter() }
func (s *session) PtyReader() io.Reader { return s.spawn.PtyReader() }
func (s *session) CopyOutputContext(ctx context.Context, dst io.Writer) error {
return copyPTYOutput(ctx, dst, s.spawn.PtyReader())
}
func (s *session) SetRawMode() error {
_, err := s.console.MakeRaw()
return err