Cygwin: pty: Fix race condition in initialization of pseudo console.

- If output of non-cygwin process is piped to cygwin process, such
  as less, the non-cygwin process sometimes fails to start and hangs.
  This patch fixes the issue.
This commit is contained in:
Takashi Yano via Cygwin-patches 2020-10-26 17:29:31 +09:00 committed by Corinna Vinschen
parent 3752ab804b
commit 7b996f807e
1 changed files with 0 additions and 9 deletions

View File

@ -784,8 +784,6 @@ fhandler_pty_slave::reset_switch_to_pcon (void)
return;
get_ttyp ()->pcon_pid = 0;
get_ttyp ()->switch_to_pcon_in = false;
get_ttyp ()->h_pseudo_console = NULL;
get_ttyp ()->pcon_start = false;
}
ssize_t __stdcall
@ -2620,7 +2618,6 @@ fhandler_pty_slave::term_has_pcon_cap (const WCHAR *env)
char *p;
int len;
int x1, y1, x2, y2;
tcflag_t c_lflag;
DWORD t0;
/* Check if terminal has ANSI escape sequence. */
@ -2629,8 +2626,6 @@ fhandler_pty_slave::term_has_pcon_cap (const WCHAR *env)
/* Check if terminal has CSI6n */
WaitForSingleObject (input_mutex, INFINITE);
c_lflag = get_ttyp ()->ti.c_lflag;
get_ttyp ()->ti.c_lflag &= ~ICANON;
/* Set h_pseudo_console and pcon_start so that the response
will sent to io_handle rather than io_handle_cyg. */
get_ttyp ()->h_pseudo_console = (HPCON *) -1; /* dummy */
@ -2687,10 +2682,7 @@ fhandler_pty_slave::term_has_pcon_cap (const WCHAR *env)
break;
}
while (len);
WaitForSingleObject (input_mutex, INFINITE);
get_ttyp ()->h_pseudo_console = NULL;
get_ttyp ()->ti.c_lflag = c_lflag;
ReleaseMutex (input_mutex);
if (len == 0)
return true;
@ -2711,7 +2703,6 @@ not_has_csi6n:
in master write(). Therefore, clear it here manually. */
get_ttyp ()->pcon_start = false;
get_ttyp ()->h_pseudo_console = NULL;
get_ttyp ()->ti.c_lflag = c_lflag;
ReleaseMutex (input_mutex);
maybe_dumb:
get_ttyp ()->pcon_cap_checked = true;