public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin-developers@cygwin.com
Subject: Re: 3.3.0: Possible regression in cygwin DLL (Win10); fixed in snapshot
Date: Wed, 17 Nov 2021 08:46:50 +0900	[thread overview]
Message-ID: <20211117084650.67be932e7762ecc8b1dbfb5d@nifty.ne.jp> (raw)
In-Reply-To: <dd79e499-f401-dffb-40c1-57b0d35542bb@cornell.edu>

[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]

On Thu, 11 Nov 2021 11:11:10 -0500
Ken Brown wrote:
> On 11/10/2021 4:32 PM, Ken Brown wrote:
> > On 11/10/2021 3:35 PM, Corinna Vinschen wrote:
> >> On Nov 10 22:30, Takashi Yano wrote:
> >>> Thanks. I have just pushed the experimental patch to topic/pipe.
> >>> Please try. If something wrong, please point it out.
> >>
> >> Great, I'll have a look.  Ken, you're looking as well, right?
> > 
> > Yes.  It looks good on a first read-through.  I want to look again and do some 
> > testing.  One minor thing I noticed is that fhandler_pipe::raw_read could be 
> > cleaned up a little more: There are still references to STATUS_THREAD_SIGNALED 
> > and STATUS_THREAD_CANCELED, which can't occur any more.
> 
> It still looks good after a second read.  I'll try using it in my normal Cygwin 
> install to make sure no problems come up.
> 
> I've pushed a cleanup patch removing STATUS_THREAD_SIGNALED and 
> STATUS_THREAD_CANCELED, as well as a patch documenting the new behavior of the 
> pipe_byte option.

I have just rebased topic/pipe to current master.

I also would like to propose patch attached for topic/pipe.
Please have a look.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

[-- Attachment #2: 0001-Cygwin-pipe-Suppress-unnecessary-set_pipe_non_blocki.patch --]
[-- Type: application/octet-stream, Size: 2290 bytes --]

From 544292f81d8914b8510f39fe07d2b05cd4e99828 Mon Sep 17 00:00:00 2001
From: "U-EXPRESS5800-S70\\yano" <takashi.yano@nifty.ne.jp>
Date: Tue, 16 Nov 2021 20:59:09 +0900
Subject: [PATCH] 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.
- Set blocking mode properly when cygwin process is executed from non-
  cygwin process.
---
 winsup/cygwin/dtable.cc | 3 +++
 winsup/cygwin/spawn.cc  | 9 ++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index d57cbb355..e54db4446 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -410,6 +410,9 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
 	{
 	  fhandler_pipe *fhp = (fhandler_pipe *) fh;
 	  fhp->set_pipe_buf_size ();
+	  /* Set read pipe always to nonblocking */
+	  fhp->set_pipe_non_blocking (fhp->get_device () == FH_PIPER ?
+				      true : fhp->is_nonblocking ());
 	}
 
       if (!fh->open_setup (openflags))
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


  parent reply	other threads:[~2021-11-16 23:47 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAEv6GOB8PXHgHoz7hdJy6Bia2GWEmUDnTd252gTGinz2vuv=hA@mail.gmail.com>
     [not found] ` <20211105123950.b118a7f2ba38379764df4c12@nifty.ne.jp>
     [not found]   ` <CAEv6GOA-y58YrftXgEgFrjqtOTHmfdu2Vrq76Lwn0suZpZ=U9w@mail.gmail.com>
     [not found]     ` <20211105170542.96ce6dd4ca32880ddfddd660@nifty.ne.jp>
     [not found]       ` <CAEv6GODiM88Xfhk9R3AcEW6UTYSzACzYe4C0gPoTYm=u9ZTqRQ@mail.gmail.com>
     [not found]         ` <20211106044116.698b465a5d8ed6ce2cc75c99@nifty.ne.jp>
     [not found]           ` <2cfa5de7-3b95-9062-4572-f36d304bc916@cornell.edu>
2021-11-06  6:10             ` Takashi Yano
2021-11-06 11:42               ` Corinna Vinschen
2021-11-06 12:02                 ` Corinna Vinschen
2021-11-06 14:13                   ` Takashi Yano
2021-11-06 17:20                     ` Corinna Vinschen
2021-11-07  3:01                       ` Takashi Yano
2021-11-06 16:38                 ` Ken Brown
2021-11-06 17:20                   ` Corinna Vinschen
2021-11-07  3:46                   ` Takashi Yano
2021-11-07 22:20                     ` Ken Brown
2021-11-08  8:23                       ` Takashi Yano
2021-11-08  9:46                         ` Corinna Vinschen
2021-11-10  8:30                 ` Takashi Yano
2021-11-10 10:34                   ` Corinna Vinschen
2021-11-10 13:30                     ` Takashi Yano
2021-11-10 20:35                       ` Corinna Vinschen
2021-11-10 21:32                         ` Ken Brown
2021-11-11 16:11                           ` Ken Brown
2021-11-12  8:38                             ` Takashi Yano
2021-11-16 23:46                             ` Takashi Yano [this message]
2021-11-17  8:10                               ` Takashi Yano
2021-11-17 15:12                                 ` Ken Brown
2021-11-11  9:52                         ` Corinna Vinschen
2021-11-11 11:12                           ` Takashi Yano
2021-11-11 11:33                             ` Corinna Vinschen
2021-11-11 12:02                               ` Takashi Yano
2021-11-11 13:20                                 ` Takashi Yano
2021-11-11 16:07                                   ` Corinna Vinschen
2021-11-12  8:33                             ` Takashi Yano
2021-11-12 10:02                               ` Corinna Vinschen
2021-12-12 13:26                                 ` Takashi Yano
2021-12-12 13:36                                   ` Ken Brown
2021-12-13 11:15                                     ` Takashi Yano

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=20211117084650.67be932e7762ecc8b1dbfb5d@nifty.ne.jp \
    --to=takashi.yano@nifty.ne.jp \
    --cc=cygwin-developers@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).