public inbox for
 help / color / mirror / Atom feed
From: Takashi Yano <>
Subject: [PATCH] Cygwin: pty: Fix a possible race issue in initialization of pcon.
Date: Fri,  4 Mar 2022 22:32:57 +0900	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

- Currently, tty::pcon_start flag is cleared before transfer_input()
  in master::write(), however, the code in setup_pseudoconsole()
  waits for transfer_input() using tty::pcon_start. This possibly
  causes the race issue. The patch fixes this potential issue.
 winsup/cygwin/ | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/ b/winsup/cygwin/
index cba25ee84..3ed84709e 100644
--- a/winsup/cygwin/
+++ b/winsup/cygwin/
@@ -3215,7 +3215,8 @@ fhandler_pty_slave::setup_pseudoconsole ()
 	  get_ttyp ()->pcon_start_pid = myself->pid;
 	  WriteFile (get_output_handle (), "\033[6n", 4, &n, NULL);
 	  ReleaseMutex (input_mutex);
-	  while (get_ttyp ()->pcon_start)
+	  while (get_ttyp ()->pcon_start_pid)
+	    /* wait for completion of transfer_input() in master::write(). */
 	    Sleep (1);
       /* Attach to the pseudo console which already exits. */

      reply	other threads:[~2022-03-04 13:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-04 13:32 [PATCH] Cygwin: pty: Update some comments in pty code Takashi Yano
2022-03-04 13:32 ` Takashi Yano [this message]

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* 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).