[PATCH v2] Cygwin: console: Abort setting disable_master_thread when no con.owner
Takashi Yano
takashi.yano@nifty.ne.jp
Tue Sep 15 08:19:03 GMT 2026
With the commit 733d5a953fa9 ("Cygwin: console: Ensure the master
thread runs only when it is supposed to"), the process which calls
set_disable_master_thread() hangs if the con.owner already exited,
because set_disable_master_thread() waits for cons_master_thread
accepting the status change and reflecting the current status to
master_thread_suspended. With this patch, set_disable_master_thread()
is aborted if the owner process no longer exists to avoid this
hang.
Addresses: https://cygwin.com/pipermail/cygwin/2026-September/260037.html
Fixes: 733d5a953fa9 ("Cygwin: console: Ensure the master thread runs only when it is supposed to")
Reported-by: Jay Libove Alzina <libove@felines.org>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
v2: Treat the absence of the master thread the same as suspension.
winsup/cygwin/fhandler/console.cc | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc
index 110e80c6b..2ae300a21 100644
--- a/winsup/cygwin/fhandler/console.cc
+++ b/winsup/cygwin/fhandler/console.cc
@@ -5029,7 +5029,17 @@ fhandler_console::set_disable_master_thread (bool x, fhandler_console *cons)
con.disable_master_thread = x;
cons->release_input_mutex ();
while (con.master_thread_suspended != x)
- Sleep (1);
+ { /* Wait for the responce from the cons_master_thread. */
+ if (con.owner == 0)
+ { /* The process that runs cons_master_thread no longer exists. */
+ cons->acquire_input_mutex (mutex_timeout);
+ /* Treat the absence of the master_thread the same as suspension. */
+ con.master_thread_suspended = true;
+ cons->release_input_mutex ();
+ return; /* Abort */
+ }
+ Sleep (1);
+ }
}
int
--
2.51.0
More information about the Cygwin-patches
mailing list