- Previously, the PID_NEW_PG flag was also used as a marker for GDB with non-cygwin inferior, unlike its original meaning. With this patch, the condition exec_dwProcessId == dwProcessId is used as a marker for that instead. --- winsup/cygwin/fhandler_termios.cc | 14 +++++++------- winsup/cygwin/fhandler_tty.cc | 11 ++++++----- winsup/cygwin/tty.cc | 4 +++- 3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc index 3740ba011..5cd44d7bf 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -341,15 +341,16 @@ fhandler_termios::process_sigs (char c, tty* ttyp, fhandler_termios *fh) { _pinfo *p = pids[i]; /* PID_NOTCYGWIN: check this for non-cygwin process. - PID_NEW_PG: check this ofr GDB with non-cygwin inferior in pty + exec_dwProcessId == dwProcessId: + check this for GDB with non-cygwin inferior in pty without pcon enabled. In this case, the inferior is not - cygwin process list. PID_NEW_PG is set as a marker for - GDB with non-cygwin inferior in pty code. + cygwin process list. This condition is set true as + a marker for GDB with non-cygwin inferior in pty code. !PID_CYGPARENT: check this for GDB with cygwin inferior or cygwin apps started from non-cygwin shell. */ if (c == '\003' && p && p->ctty == ttyp->ntty && p->pgid == pgid && ((p->process_state & PID_NOTCYGWIN) - || (p->process_state & PID_NEW_PG) + || (p->exec_dwProcessId == p->dwProcessId) || !(p->process_state & PID_CYGPARENT))) { /* Ctrl-C event will be sent only to the processes attaching @@ -369,8 +370,7 @@ fhandler_termios::process_sigs (char c, tty* ttyp, fhandler_termios *fh) /* CTRL_C_EVENT does not work for the process started with CREATE_NEW_PROCESS_GROUP flag, so send CTRL_BREAK_EVENT instead. */ - if ((p->process_state & PID_NEW_PG) - && (p->process_state & PID_NOTCYGWIN)) + if (p->process_state & PID_NEW_PG) GenerateConsoleCtrlEvent (CTRL_BREAK_EVENT, p->dwProcessId); else if ((!fh || fh->need_send_ctrl_c_event () || cyg_leader) && !ctrl_c_event_sent) /* cyg_leader is needed by GDB @@ -405,7 +405,7 @@ fhandler_termios::process_sigs (char c, tty* ttyp, fhandler_termios *fh) && (p->process_state & PID_DEBUGGED)) with_debugger = true; /* inferior is cygwin app */ if (!(p->process_state & PID_NOTCYGWIN) - && (p->process_state & PID_NEW_PG) /* Check marker */ + && (p->exec_dwProcessId == p->dwProcessId) /* Check marker */ && p->pid == pgid) with_debugger_nat = true; /* inferior is non-cygwin app */ } diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index c7588a073..52f0b8622 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -116,8 +116,9 @@ fhandler_pty_common::get_console_process_id (DWORD pid, bool match, return res_pri ?: res; } -static bool isHybrid; /* Set true if the active pipe is set to nat pipe even - though the current process is a cygwin process. */ +static bool isHybrid; /* Set true if the active pipe is set to nat pipe + owned by myself even though the current process + is a cygwin process. */ static HANDLE h_gdb_inferior; /* Handle of GDB inferior process. */ static void @@ -1079,8 +1080,9 @@ fhandler_pty_slave::set_switch_to_nat_pipe (void) { isHybrid = true; setup_locale (); - myself->exec_dwProcessId = myself->dwProcessId; - myself->process_state |= PID_NEW_PG; /* Marker for nat_fg */ + myself->exec_dwProcessId = myself->dwProcessId; /* Set this as a marker + for tty::nat_fg() + and process_sigs() */ bool stdin_is_ptys = GetStdHandle (STD_INPUT_HANDLE) == get_handle (); setup_for_non_cygwin_app (false, NULL, stdin_is_ptys); } @@ -1199,7 +1201,6 @@ fhandler_pty_slave::reset_switch_to_nat_pipe (void) } } myself->exec_dwProcessId = 0; - myself->process_state &= ~PID_NEW_PG; isHybrid = false; } } diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index b2218fef7..60f4a602a 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -342,7 +342,9 @@ tty::nat_fg (pid_t pgid) { _pinfo *p = pids[i]; if (p->ctty == ntty && p->pgid == pgid - && (p->process_state & (PID_NOTCYGWIN | PID_NEW_PG))) + && ((p->process_state & PID_NOTCYGWIN) + /* Below is true for GDB with non-cygwin inferior */ + || p->exec_dwProcessId == p->dwProcessId)) return true; } if (pgid > MAX_PID) -- 2.35.1