Cygwin: pipe: Restore blocking mode of read pipe on close() #72
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.
As of cygwin/cygwin@fc691d0246b9, which was backported to the
cygwin-3_5-branchas cygwin/cygwin@55431b4, which in turn was backported into Git for Windows as a4d92d6, read pipes are essentially always marked as non-blocking.This strategy fails to take into account that pipes that were originally marked as blocking when they were created outside of MSYS/Cygwin are typically expected to remain in blocking mode by the processes that created them.
This leads to problems, e.g. the unfortunate symptom where using VSCode's built-in
askpasshelper, Git operations fail with this rather cryptic error message:Work around this not by leaving the blocking/non-blocking mode alone, but instead by still forcing the read pipe to non-blocking mode as long as Cygwin reads it yet ensuring that the mode is restored when the MSYS/Cygwin end of the pipe is closed. This logic would not appear to be thread-safe in the hope that it does not matter in practice.
This addresses git-for-windows/git#5115
/cc @tyan0