-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cygwin: pipe: Restore blocking mode of read pipe on close() #72
Conversation
If a cygwin app is executed from a non-cygwin app and the cygwin app exits, read pipe remains on non-blocking mode because of the commit fc691d0246b9. Due to this behaviour, the non-cygwin app cannot read the pipe correctly after that. With this patch, the blocking mode of the read pipe is stored into was_blocking_read_pipe on set_pipe_non_blocking() when the cygwin app starts and restored on close(). Addresses: git-for-windows/git#5115 Fixes: fc691d0246b9 ("Cygwin: pipe: Make sure to set read pipe non-blocking for cygwin apps."); Reported-by: isaacag, Johannes Schindelin <Johannes.Schindelin@gmx.de> Reported-at: git-for-windows/git#5115 Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
There is now already a v4.2 (I am a bit confused what the .2 stands for, I don't find any clear explanation for it) but it has issues. My hand is forced quite a bit by Git v2.46.1 having been released yesterday and the corresponding Git for Windows version seems the only realistic chance to fix this issue for Windows 7 and Windows 8 users (because Git for Windows v2.47 will drop support for those Windows versions). So I'll just go ahead and merge this, and then prepare a corresponding MSYS2-packages PR and deploy the msys2-runtime package. |
The Cygwin runtime (and for that reason, the MSYS2 runtime, too), change pipes from blocking to non-blocking, which is a problem when the pipe is actually opened by something like Git when it asks a credential helper for information. Git, not expecting the pipe mode to be changed behind its back, will then error out with "fatal: read error: Invalid argument". To address this, this patch was proposed in the Cygwin project as https://inbox.sourceware.org/cygwin-patches/20240830141553.12128-1-takashi.yano@nifty.ne.jp/ Ideally, Cygwin would not even _try_ to fiddle with the pipe mode, therefore this patch was not applied as-is. At time of writing, there is no consensus on any replacement patch, but I have to prepare _something_ for the already-late Git for Windows v2.46.1 (which is likely the last Git for Windows version to support Windows 7 and Windows 8, hence the urgency). And this patch at least improves the situation. This patch will be dropped when Git for Windows will upgrade to MSYS2 runtime v3.5, and hopefully consensus will have been reached about a better fix by that time. This commit corresponds to git-for-windows/msys2-runtime#72 which fixes git-for-windows/git#5115. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
The Cygwin runtime (and for that reason, the MSYS2 runtime, too), change pipes from blocking to non-blocking, which is a problem when the pipe is actually opened by something like Git when it asks a credential helper for information. Git, not expecting the pipe mode to be changed behind its back, will then error out with "fatal: read error: Invalid argument". To address this, this patch was proposed in the Cygwin project as https://inbox.sourceware.org/cygwin-patches/20240830141553.12128-1-takashi.yano@nifty.ne.jp/ Ideally, Cygwin would not even _try_ to fiddle with the pipe mode, therefore this patch was not applied as-is. At time of writing, there is no consensus on any replacement patch, but I have to prepare _something_ for the already-late Git for Windows v2.46.1 (which is likely the last Git for Windows version to support Windows 7 and Windows 8, hence the urgency). And this patch at least improves the situation. This patch will be dropped when Git for Windows will upgrade to MSYS2 runtime v3.5, and hopefully consensus will have been reached about a better fix by that time. This commit corresponds to git-for-windows/msys2-runtime#72 which fixes git-for-windows/git#5115. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
…ng-mode Cygwin: pipe: Restore blocking mode of read pipe on close()
This includes the pull request git-for-windows#72 from dscho/restore-pipes-blocking-mode, and adds two more backported patches. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
As of cygwin/cygwin@fc691d0246b9, which was backported to the
cygwin-3_5-branch
as 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
askpass
helper, 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