public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Jeremy Drake <cygwin@jdrake.com>
To: Takashi Yano <takashi.yano@nifty.ne.jp>
Cc: cygwin-patches@cygwin.com
Subject: Re: [PATCH v4] Cygwin: pipe: Avoid deadlock for non-cygwin writer.
Date: Tue, 29 Mar 2022 08:21:11 -0700 (PDT)	[thread overview]
Message-ID: <alpine.BSO.2.21.2203290816270.56460@resin.csoft.net> (raw)
In-Reply-To: <20220329090753.47207-1-takashi.yano@nifty.ne.jp>

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?

  reply	other threads:[~2022-03-29 15:21 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 [this message]
2022-03-30  0:17   ` Takashi Yano
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=alpine.BSO.2.21.2203290816270.56460@resin.csoft.net \
    --to=cygwin@jdrake.com \
    --cc=cygwin-patches@cygwin.com \
    --cc=takashi.yano@nifty.ne.jp \
    /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).