From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin-patches@cygwin.com
Subject: [PATCH] Cygwin: pipe: Suppress unnecessary set_pipe_non_blocking() call.
Date: Wed, 17 Nov 2021 17:08:27 +0900 [thread overview]
Message-ID: <20211117080827.1800-1-takashi.yano@nifty.ne.jp> (raw)
- Call set_pipe_non_blocking(false) only if the pipe will be really
inherited to non-cygwin process.
---
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);
--
2.33.0
next reply other threads:[~2021-11-17 8:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-17 8:08 Takashi Yano [this message]
2021-11-17 15:09 ` Ken Brown
2021-11-17 18:22 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211117080827.1800-1-takashi.yano@nifty.ne.jp \
--to=takashi.yano@nifty.ne.jp \
--cc=cygwin-patches@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).