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.
This commit is contained in:
Takashi Yano 2022-03-04 22:02:35 +09:00
parent 3d46583d4f
commit 51095fe2ba
1 changed files with 2 additions and 1 deletions

View File

@ -3215,7 +3215,8 @@ fhandler_pty_slave::setup_pseudoconsole ()
get_ttyp ()->pcon_start_pid = myself->pid; get_ttyp ()->pcon_start_pid = myself->pid;
WriteFile (get_output_handle (), "\033[6n", 4, &n, NULL); WriteFile (get_output_handle (), "\033[6n", 4, &n, NULL);
ReleaseMutex (input_mutex); 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); Sleep (1);
} }
/* Attach to the pseudo console which already exits. */ /* Attach to the pseudo console which already exits. */