public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/cygwin-3_4-branch] Cygwin: pty: Fix failure to clear switch_to_nat_pipe flag.
@ 2023-08-19 6:08 Takashi Yano
0 siblings, 0 replies; only message in thread
From: Takashi Yano @ 2023-08-19 6:08 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3cfd7896ea51f28e55db4f22cfdfeec2c3011aff
commit 3cfd7896ea51f28e55db4f22cfdfeec2c3011aff
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date: Sat Aug 19 14:10:16 2023 +0900
Cygwin: pty: Fix failure to clear switch_to_nat_pipe flag.
After the commit fbfea31dd9b9, switch_to_nat_pipe is not cleared
properly when non-cygwin app is terminated in the case where the
pseudo console is disabled. This is because get_winpid_to_hand_over()
sometimes returns PID of cygwin process even though it should return
only PID of non-cygwin process. This patch fixes the issue by adding
a new argument which requests only PID of non-cygwin process to
get_console_process_id().
Fixes: fbfea31dd9b9 ("Cygwin: pty: Avoid cutting the branch the pty master is sitting on.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diff:
---
winsup/cygwin/fhandler/pty.cc | 11 ++++++++---
winsup/cygwin/local_includes/fhandler.h | 3 ++-
winsup/cygwin/release/3.4.9 | 6 ++++++
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
index df37d9189..aff899b1d 100644
--- a/winsup/cygwin/fhandler/pty.cc
+++ b/winsup/cygwin/fhandler/pty.cc
@@ -85,7 +85,8 @@ inline static bool process_alive (DWORD pid);
stub_only: return only stub process's pid of non-cygwin process. */
DWORD
fhandler_pty_common::get_console_process_id (DWORD pid, bool match,
- bool cygwin, bool stub_only)
+ bool cygwin, bool stub_only,
+ bool nat)
{
tmp_pathbuf tp;
DWORD *list = (DWORD *) tp.c_get ();
@@ -109,6 +110,8 @@ fhandler_pty_common::get_console_process_id (DWORD pid, bool match,
else
{
pinfo p (cygwin_pid (list[i]));
+ if (nat && !!p && !ISSTATE(p, PID_NOTCYGWIN))
+ continue;
if (!!p && p->exec_dwProcessId)
{
res_pri = stub_only ? p->exec_dwProcessId : list[i];
@@ -3561,9 +3564,11 @@ fhandler_pty_slave::get_winpid_to_hand_over (tty *ttyp,
{
/* Search another native process which attaches to the same console */
DWORD current_pid = myself->exec_dwProcessId ?: myself->dwProcessId;
- switch_to = get_console_process_id (current_pid, false, true, true);
+ switch_to = get_console_process_id (current_pid,
+ false, true, true, true);
if (!switch_to)
- switch_to = get_console_process_id (current_pid, false, true, false);
+ switch_to = get_console_process_id (current_pid,
+ false, true, false, true);
}
return switch_to;
}
diff --git a/winsup/cygwin/local_includes/fhandler.h b/winsup/cygwin/local_includes/fhandler.h
index 5619e2289..abff2e08f 100644
--- a/winsup/cygwin/local_includes/fhandler.h
+++ b/winsup/cygwin/local_includes/fhandler.h
@@ -2377,7 +2377,8 @@ class fhandler_pty_common: public fhandler_termios
void resize_pseudo_console (struct winsize *);
static DWORD get_console_process_id (DWORD pid, bool match,
bool cygwin = false,
- bool stub_only = false);
+ bool stub_only = false,
+ bool nat = false);
bool to_be_read_from_nat_pipe (void);
static DWORD attach_console_temporarily (DWORD target_pid, DWORD helper_pid);
static void resume_from_temporarily_attach (DWORD resume_pid);
diff --git a/winsup/cygwin/release/3.4.9 b/winsup/cygwin/release/3.4.9
new file mode 100644
index 000000000..d089e5a9a
--- /dev/null
+++ b/winsup/cygwin/release/3.4.9
@@ -0,0 +1,6 @@
+Bug Fixes
+---------
+
+- Fix a bug introduced in cygwin 3.4.0 that switch_to_nat_pipe flag is
+ not cleared properly when non-cygwin app is terminated in the case
+ where pseudo console is not activated.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-19 6:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-19 6:08 [newlib-cygwin/cygwin-3_4-branch] Cygwin: pty: Fix failure to clear switch_to_nat_pipe flag Takashi Yano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).