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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

cygwin-patches mailing list
- 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.
---
 winsup/cygwin/fhandler_tty.cc | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 8910af1e7..c5a081ebd 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -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;
--
2.29.0

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Cygwin: pty: Fix race condition in initialization of pseudo console.

Corinna Vinschen-2
On Oct 26 17:29, Takashi Yano via Cygwin-patches wrote:
> - 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.
> ---
>  winsup/cygwin/fhandler_tty.cc | 9 ---------
>  1 file changed, 9 deletions(-)

Pushed.


Thanks,
Corinna