Repository navigation
term: support stream interfaces in GetFdInfo - #63
Merged
Merged
Conversation
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>
There was a problem hiding this comment.
🟢 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
Member
Author
|
cc @vvoland ptal |
vvoland
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.