diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2024-09-05 11:36:27 +0900 |
---|---|---|
committer | Takashi Yano <takashi.yano@nifty.ne.jp> | 2024-11-01 04:50:45 +0900 |
commit | 7ed9adb356df61114bb3fa3d0efc098c0501921c (patch) | |
tree | b097807039dfbdc608f46d4cf751ce4235a96223 /winsup/cygwin/spawn.cc | |
parent | 1f05c040599afe63af8c7ecfe71bc461f393600d (diff) | |
download | newlib-7ed9adb356df61114bb3fa3d0efc098c0501921c.zip newlib-7ed9adb356df61114bb3fa3d0efc098c0501921c.tar.gz newlib-7ed9adb356df61114bb3fa3d0efc098c0501921c.tar.bz2 |
Cygwin: pipe: Switch pipe mode to blocking mode by default
Previously, cygwin read pipe used non-blocking mode although non-
cygwin app uses blocking-mode by default. Despite this requirement,
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. Similarly, if a non-
cygwin app is executed from a cygwin app and the non-cygwin app
exits, the read pipe mode remains on blocking mode although cygwin
read pipe should be non-blocking mode.
These bugs were provoked by pipe mode toggling between cygwin and
non-cygwin apps. To make management of pipe mode simpler, this
patch has re-designed the pipe implementation. In this new
implementation, both read and write pipe basically use only blocking
mode and the behaviour corresponding to the pipe mode is simulated
in raw_read() and raw_write(). Only when NtQueryInformationFile
(FilePipeLocalInformation) fails for some reasons, the raw_read()/
raw_write() cannot simulate non-blocking access. Therefore, the pipe
mode is temporarily changed to non-blocking mode.
Moreover, because the fact that NtSetInformationFile() in
set_pipe_non_blocking(true) fails with STATUS_PIPE_BUSY if the pipe
is not empty has been found, query handle is not necessary anymore.
This allows the implementation much simpler than before.
Addresses: https://github.com/git-for-windows/git/issues/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>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>, Ken Brown <kbrown@cornell.edu>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r-- | winsup/cygwin/spawn.cc | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index ecc60dc..60a8299 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -579,10 +579,6 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, int fileno_stdout = in__stdout < 0 ? 1 : in__stdout; int fileno_stderr = 2; - if (!iscygwin ()) - fhandler_pipe::spawn_worker (fileno_stdin, fileno_stdout, - fileno_stderr); - bool no_pcon = mode != _P_OVERLAY && mode != _P_WAIT; term_spawn_worker.setup (iscygwin (), handle (fileno_stdin, false), runpath, no_pcon, reset_sendsig, envblock); |