From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 24E34385AC1D; Wed, 17 Nov 2021 18:32:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24E34385AC1D Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_3-branch] Cygwin: pipe: Suppress unnecessary set_pipe_non_blocking() call. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/cygwin-3_3-branch X-Git-Oldrev: d0276bc60b7088f406867aeeffd113cb38d78533 X-Git-Newrev: bf9cef4c4ee11b767f939a87b817d3cb74e15131 Message-Id: <20211117183208.24E34385AC1D@sourceware.org> Date: Wed, 17 Nov 2021 18:32:08 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Nov 2021 18:32:08 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=bf9cef4c4ee11b767f939a87b817d3cb74e15131 commit bf9cef4c4ee11b767f939a87b817d3cb74e15131 Author: Takashi Yano Date: Wed Nov 17 12:39:04 2021 +0900 Cygwin: pipe: Suppress unnecessary set_pipe_non_blocking() call. - Call set_pipe_non_blocking(false) only if the pipe will be really inherited to non-cygwin process. Diff: --- winsup/cygwin/spawn.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 6b2026776..e160fa3bb 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -648,8 +648,9 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, if (!iscygwin ()) { + int fd; cfd.rewind (); - while (cfd.next () >= 0) + while ((fd = cfd.next ()) >= 0) if (cfd->get_major () == DEV_PTYS_MAJOR) { fhandler_pty_slave *ptys = @@ -657,13 +658,15 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, ptys->create_invisible_console (); ptys->setup_locale (); } - else if (cfd->get_dev () == FH_PIPEW) + else if (cfd->get_dev () == FH_PIPEW + && (fd == (in__stdout < 0 ? 1 : in__stdout) || fd == 2)) { fhandler_pipe *pipe = (fhandler_pipe *)(fhandler_base *) cfd; pipe->close_query_handle (); pipe->set_pipe_non_blocking (false); } - else if (cfd->get_dev () == FH_PIPER) + else if (cfd->get_dev () == FH_PIPER + && fd == (in__stdin < 0 ? 0 : in__stdin)) { fhandler_pipe *pipe = (fhandler_pipe *)(fhandler_base *) cfd; pipe->set_pipe_non_blocking (false);