]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: pty: Fix input switching failure.
authorTakashi Yano <takashi.yano@nifty.ne.jp>
Wed, 15 Dec 2021 03:25:58 +0000 (12:25 +0900)
committerTakashi Yano <takashi.yano@nifty.ne.jp>
Wed, 15 Dec 2021 03:25:58 +0000 (12:25 +0900)
- This patch fixes the failure of input switching between io_handle
  and io_handle_nat. This very rarely happens, however, input is
  wrongly switched to io_handle_nat even though the non-cygwin app
  is in the background.

winsup/cygwin/fhandler_tty.cc
winsup/cygwin/tty.cc

index ee687d9adf663984d30ea15767320b0d657bfe06..c8ad53cb78fef085e98cc9e8a6a5986e8a39db77 100644 (file)
@@ -1056,6 +1056,7 @@ fhandler_pty_slave::set_switch_to_pcon (void)
       isHybrid = true;
       setup_locale ();
       myself->exec_dwProcessId = myself->dwProcessId;
+      myself->process_state |= PID_NEW_PG; /* Marker for pcon_fg */
       bool nopcon = (disable_pcon || !term_has_pcon_cap (NULL));
       WaitForSingleObject (pcon_mutex, INFINITE);
       bool pcon_enabled = setup_pseudoconsole (nopcon);
@@ -1168,6 +1169,7 @@ fhandler_pty_slave::reset_switch_to_pcon (void)
                    }
                }
              myself->exec_dwProcessId = 0;
+             myself->process_state &= ~PID_NEW_PG;
              isHybrid = false;
            }
        }
@@ -2272,6 +2274,7 @@ fhandler_pty_master::write (const void *ptr, size_t len)
              _pinfo *p = pids[i];
              if (p->ctty == get_ttyp ()->ntty
                  && p->pgid == get_ttyp ()->getpgid ()
+                 && (p->process_state & PID_NOTCYGWIN)
                  && (p->process_state & PID_NEW_PG))
                {
                  wpid = p->dwProcessId;
index 2566f4c457445ec07650e09a7650c6774d3cc767..11ad3ec51f2ba25e03aabdc664b96e9a10f9d437 100644 (file)
@@ -392,7 +392,8 @@ tty::pcon_fg (pid_t pgid)
   for (unsigned i = 0; i < pids.npids; i++)
     {
       _pinfo *p = pids[i];
-      if (p->ctty == ntty && p->pgid == pgid && p->exec_dwProcessId)
+      if (p->ctty == ntty && p->pgid == pgid
+         && (p->process_state & (PID_NOTCYGWIN | PID_NEW_PG)))
        return true;
     }
   if (pgid > MAX_PID)
This page took 0.031174 seconds and 5 git commands to generate.