public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH v4] Cygwin: pipe: Avoid deadlock for non-cygwin writer.
Date: Wed, 30 Mar 2022 09:17:16 +0900	[thread overview]
Message-ID: <20220330091716.f4541fdff98f2b0aa0c1ec2f@nifty.ne.jp> (raw)
In-Reply-To: <alpine.BSO.2.21.2203290816270.56460@resin.csoft.net>

On Tue, 29 Mar 2022 08:21:11 -0700 (PDT)
Jeremy Drake wrote:

> On Tue, 29 Mar 2022, Takashi Yano wrote:
> 
> > diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
> > index fb3d09d84..cd2d3a7ef 100644
> > --- a/winsup/cygwin/spawn.cc
> > +++ b/winsup/cygwin/spawn.cc
> > @@ -645,8 +646,18 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
> >  		     && (fd == fileno_stdout || fd == fileno_stderr))
> >  	      {
> >  		fhandler_pipe *pipe = (fhandler_pipe *)(fhandler_base *) cfd;
> > -		pipe->close_query_handle ();
> >  		pipe->set_pipe_non_blocking (false);
> > +		pipe->request_close_query_hdl ();
> > +
> > +		tty_min dummy_tty;
> > +		dummy_tty.ntty = (fh_devices) myself->ctty;
> > +		dummy_tty.pgid = myself->pgid;
> > +		tty_min *t = cygwin_shared->tty.get_cttyp ();
> > +		if (!t) /* If tty is not allocated, use dummy_tty instead. */
> > +		  t = &dummy_tty;
> > +		/* Emit __SIGNONCYGCHLD to let all processes in the
> > +		   process group close query_hdl. */
> > +		t->kill_pgrp (__SIGNONCYGCHLD);
> >  	      }
> >  	    else if (cfd->get_dev () == FH_PIPER && fd == fileno_stdin)
> >  	      {
> >
> 
> This block seems to be inside a loop over handles.  Would it make sense to
> move the `tty_min dummy_tty` through `t->kill_pgrp` lines outside the
> loop, and set a flag in the loop instead, so the pgrp only needs to be
> signaled (killed) once rather than for each handle that needs closing?

Thanks for the advice. I will submit v5 patch reflecting your advice.

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

  reply	other threads:[~2022-03-30  0:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29  9:07 Takashi Yano
2022-03-29 15:21 ` Jeremy Drake
2022-03-30  0:17   ` Takashi Yano [this message]
2022-04-01  8:44     ` Takashi Yano
2022-03-29 15:40 ` Jeremy Drake

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=20220330091716.f4541fdff98f2b0aa0c1ec2f@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).