public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/cygwin-3_3-branch] Cygwin: pty: Fix a possible race issue in initialization of pcon.
@ 2022-03-04 13:37 Takashi Yano
  0 siblings, 0 replies; only message in thread
From: Takashi Yano @ 2022-03-04 13:37 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=09a54135cecacc2fcdc844fcf12a73c8191439e0

commit 09a54135cecacc2fcdc844fcf12a73c8191439e0
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Fri Mar 4 22:02:35 2022 +0900

    Cygwin: pty: Fix a possible race issue in initialization of pcon.
    
    - 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.

Diff:
---
 winsup/cygwin/fhandler_tty.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 2d7e2cf69..a97460660 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -3297,7 +3297,8 @@ fhandler_pty_slave::setup_pseudoconsole (bool nopcon)
 	  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. */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-04 13:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04 13:37 [newlib-cygwin/cygwin-3_3-branch] Cygwin: pty: Fix a possible race issue in initialization of pcon Takashi Yano

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