windows: identify standard streams by console handle, not value identity - #90
Open
ndeloof wants to merge 1 commit into
Open
windows: identify standard streams by console handle, not value identity#90ndeloof wants to merge 1 commit into
ndeloof wants to merge 1 commit into
Conversation
newMaster rejected any File that was not literally os.Stdin, os.Stdout or os.Stderr — a Go pointer-identity check. Callers commonly hand over a wrapper decorating a standard stream to satisfy the File interface (their CLI stream types don't implement it directly); such a wrapper reports the very same console handle through Fd() and designates the same console object, yet was rejected with "creating a console from a file is not supported on windows". Concrete fallout: docker/compose#14086 — the compose build progress passes its CLI stream wrapped as a File, so the TTY rendering could never engage on Windows (silent fallback to plain in auto mode, hard failure with --progress=tty). Compare the underlying handles instead: the invariant is unchanged — only the process's standard streams are accepted, since the console-mode operations act on those handles — but it is now expressed against the console object rather than the Go value. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
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.
On Windows,
newMasterrejected anyFilethat was not literallyos.Stdin,os.Stdoutoros.Stderr— a Go pointer-identity check. Callers commonly hand over a wrapper decorating a standard stream to satisfy theFileinterface (their CLI stream types don't implement it directly); such a wrapper reports the very same console handle throughFd()and designates the same console object, yet was rejected withcreating a console from a file is not supported on windows.Concrete fallout: docker/compose#14086 — compose's build progress passes its CLI output stream wrapped as a
File, so the TTY rendering could never engage on Windows: silent fallback to plain in auto mode, hard failure with--progress=tty.This PR compares the underlying handles instead. The invariant is unchanged — only the process's standard streams are accepted, since the console-mode operations act on those handles — but it is now expressed against the console object rather than the Go value. Wrappers over any other handle stay rejected.
Includes a unit test covering the three std streams, their wrapped forms, and the rejection of regular-file handles; it runs in headless CI since
initStdiostolerates redirected streams.