Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2022-03-04 16:02:35 +0300
committerTakashi Yano <takashi.yano@nifty.ne.jp>2022-03-04 16:23:39 +0300
commit51095fe2ba9d109e34251d7221fe0bf768ec749b (patch)
tree0a75ec7579e7bbc7350ffa8866b20d1ccd6a52c4
parent3d46583d4fa89f1c188bb169da939d769765bc67 (diff)
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.
-rw-r--r--winsup/cygwin/fhandler_tty.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index cba25ee84..3ed84709e 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -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. */