This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH 1/2] Cygwin: pty: Add a workaround for ^C handling.
- From: Takashi Yano <takashi dot yano at nifty dot ne dot jp>
- To: cygwin-patches at cygwin dot com
- Cc: Takashi Yano <takashi dot yano at nifty dot ne dot jp>
- Date: Wed, 4 Sep 2019 10:46:17 +0900
- Subject: [PATCH 1/2] Cygwin: pty: Add a workaround for ^C handling.
- Dkim-filter: OpenDKIM Filter v2.10.3 conuserg-06.nifty.com x841kPmX024773
- References: <20190904014618.1372-1-takashi.yano@nifty.ne.jp>
- Pseudo console support introduced by commit
169d65a5774acc76ce3f3feeedcbae7405aa9b57 sometimes cause random
crash or freeze by pressing ^C while cygwin and non-cygwin
processes are executed simultaneously in the same pty. This
patch is a workaround for this issue.
---
winsup/cygwin/fhandler_tty.cc | 5 +++++
winsup/cygwin/spawn.cc | 6 ++++++
2 files changed, 11 insertions(+)
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 240ee017c..283558985 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2846,6 +2846,9 @@ fhandler_pty_slave::fixup_after_fork (HANDLE parent)
// fork_fixup (parent, inuse, "inuse");
// fhandler_pty_common::fixup_after_fork (parent);
report_tty_counts (this, "inherited", "");
+ if (getPseudoConsole ())
+ myself->ctty = 0; /* Avoid setting init_console_handler() in fork.cc.
+ This is a workaround for ^C handling problem. */
}
void
@@ -2882,6 +2885,8 @@ fhandler_pty_slave::fixup_after_exec ()
FreeConsole ();
}
}
+ if (getPseudoConsole () && myself->ctty == 0)
+ myself->ctty = get_ttyp ()->ntty; /* Restore ctty */
#if USE_API_HOOK
/* Hook Console API */
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 4bb28c47b..22dafbce3 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -634,6 +634,12 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
}
if (ptys)
ptys->fixup_after_attach (!iscygwin ());
+ if (attach_to_pcon && !iscygwin ())
+ {
+ myself->ctty = 0; /* Random freezes caused by ^C can be avoided
+ with this. */
+ init_console_handler (true);
+ }
loop:
/* When ruid != euid we create the new process under the current original
--
2.21.0