Skip to content

term: support stream interfaces in GetFdInfo - #63

Merged
thaJeztah merged 2 commits into
moby:mainfrom
thaJeztah:stream_compat
Oct 20, 2026
Merged

thaJeztah merged 2 commits into
moby:mainfrom
thaJeztah:stream_compat

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

term: rename unix-only test file

These tests use github.com/creack/pty, which currently does not
support windows.

term: support stream interfaces in GetFdInfo

Allow GetFdInfo to obtain the file descriptor and terminal status
from streams implementing FD() and IsTerminal().

This supports stream wrappers such as docker/cli's streams.Out, which
may override terminal detection or wrap an underlying file. Previously,
GetFdInfo only recognized *os.File and platform-specific wrappers,
causing terminal detection to fail for these streams.

Preserve the existing platform-specific handling as a fallback, and
extend the tests to cover stream wrappers and verify that their reported
terminal status takes precedence over OS-level detection.

These tests use github.com/creack/pty, which currently does not
support windows.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Allow GetFdInfo to obtain the file descriptor and terminal status
from streams implementing FD() and IsTerminal().

This supports stream wrappers such as docker/cli's streams.Out, which
may override terminal detection or wrap an underlying file. Previously,
GetFdInfo only recognized *os.File and platform-specific wrappers,
causing terminal detection to fail for these streams.

Preserve the existing platform-specific handling as a fallback, and
extend the tests to cover stream wrappers and verify that their reported
terminal status takes precedence over OS-level detection.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused implementation preserves existing behavior and covers the new interface handling with no identified blocking issues.

No open issues 🎉

What changed in this PR

Extends GetFdInfo to support stream wrappers that expose FD() and IsTerminal(), while preserving platform-specific fallbacks.

Changes:

  • Prefer stream-provided descriptors and terminal status.
  • Add Windows stream tests and expand Unix tests to cover terminal-status overrides.
File Description
term.go Adds stream-interface detection before the existing fallback.
term_windows_test.go Tests descriptor forwarding and stream-reported terminal status.
term_unix_test.go Tests wrappers alongside files and verifies terminal-status precedence.

Review effort: Balanced

@thaJeztah
thaJeztah requested a review from vvoland October 19, 2026 17:55
@thaJeztah

Copy link
Copy Markdown
Member Author

cc @vvoland ptal

@thaJeztah
thaJeztah merged commit 73193d7 into moby:main Oct 20, 2026
11 checks passed
@thaJeztah
thaJeztah deleted the stream_compat branch October 20, 2026 10:53
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.

3 participants