* [PATCH 0/3] Fix behaviour of non-cygwin apps in background.
@ 2021-12-12 13:04 Takashi Yano
2021-12-12 13:04 ` [PATCH 1/3] Cygwin: pty: Fix Ctrl-C handling for " Takashi Yano
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Takashi Yano @ 2021-12-12 13:04 UTC (permalink / raw)
To: cygwin-patches
Takashi Yano (3):
Cygwin: pty: Fix Ctrl-C handling for non-cygwin apps in background.
Cygwin: pty: Fix console mode of non-cygwin apps in background.
Cygwin: console: Fix console mode of non-cygwin apps in background.
winsup/cygwin/fhandler_tty.cc | 12 +++++++-----
winsup/cygwin/spawn.cc | 7 +++++--
2 files changed, 12 insertions(+), 7 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] Cygwin: pty: Fix Ctrl-C handling for non-cygwin apps in background.
2021-12-12 13:04 [PATCH 0/3] Fix behaviour of non-cygwin apps in background Takashi Yano
@ 2021-12-12 13:04 ` Takashi Yano
2021-12-12 13:05 ` [PATCH 2/3] Cygwin: pty: Fix console mode of " Takashi Yano
2021-12-12 13:05 ` [PATCH 3/3] Cygwin: console: " Takashi Yano
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Yano @ 2021-12-12 13:04 UTC (permalink / raw)
To: cygwin-patches
- With pseudo console enabled, if the non-cygwin app is started in
the background and put it into the foreground, the process cannot
be stopped by Ctrl-C. This patch fixes the issue.
---
winsup/cygwin/fhandler_tty.cc | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index dae00efd7..904398179 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2249,9 +2249,12 @@ fhandler_pty_master::write (const void *ptr, size_t len)
&mbp);
}
- if ((ti.c_lflag & ISIG) && !(ti.c_lflag & NOFLSH)
- && memchr (buf, '\003', nlen))
- get_ttyp ()->discard_input = true;
+ if ((ti.c_lflag & ISIG) && memchr (buf, '\003', nlen))
+ {
+ get_ttyp ()->kill_pgrp (SIGINT);
+ if (!(ti.c_lflag & NOFLSH))
+ get_ttyp ()->discard_input = true;
+ }
DWORD n;
WriteFile (to_slave_nat, buf, nlen, &n, NULL);
ReleaseMutex (input_mutex);
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] Cygwin: pty: Fix console mode of non-cygwin apps in background.
2021-12-12 13:04 [PATCH 0/3] Fix behaviour of non-cygwin apps in background Takashi Yano
2021-12-12 13:04 ` [PATCH 1/3] Cygwin: pty: Fix Ctrl-C handling for " Takashi Yano
@ 2021-12-12 13:05 ` Takashi Yano
2021-12-12 13:05 ` [PATCH 3/3] Cygwin: console: " Takashi Yano
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Yano @ 2021-12-12 13:05 UTC (permalink / raw)
To: cygwin-patches
- If the non-cygwin app is started in the background in pseudo
console, the console mode is broken for the app. This patch fixes
the issue.
---
winsup/cygwin/fhandler_tty.cc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 904398179..cd0de9bc0 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -3384,7 +3384,7 @@ skip_create:
if (get_ttyp ()->previous_output_code_page)
SetConsoleOutputCP (get_ttyp ()->previous_output_code_page);
- do
+ if (get_ttyp ()->getpgid () == myself->pgid)
{
termios &t = get_ttyp ()->ti;
DWORD mode;
@@ -3409,7 +3409,6 @@ skip_create:
mode |= DISABLE_NEWLINE_AUTO_RETURN;
SetConsoleMode (hpConOut, mode);
}
- while (false);
return true;
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] Cygwin: console: Fix console mode of non-cygwin apps in background.
2021-12-12 13:04 [PATCH 0/3] Fix behaviour of non-cygwin apps in background Takashi Yano
2021-12-12 13:04 ` [PATCH 1/3] Cygwin: pty: Fix Ctrl-C handling for " Takashi Yano
2021-12-12 13:05 ` [PATCH 2/3] Cygwin: pty: Fix console mode of " Takashi Yano
@ 2021-12-12 13:05 ` Takashi Yano
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Yano @ 2021-12-12 13:05 UTC (permalink / raw)
To: cygwin-patches
- If the non-cygwin app is started in the background in console, the
console mode is broken for the app. This patch fixes the issue.
---
winsup/cygwin/spawn.cc | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index e160fa3bb..465fb5fc3 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -631,11 +631,14 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
cons_ti = &((tty *)cons->tc ())->ti;
cons_owner = cons->get_owner ();
}
+ tty::cons_mode conmode =
+ (ctty_pgid && ctty_pgid == myself->pgid) ?
+ tty::native : tty::restore;
if (fd == 0)
- fhandler_console::set_input_mode (tty::native,
+ fhandler_console::set_input_mode (conmode,
cons_ti, cons->get_handle_set ());
else if (fd == 1 || fd == 2)
- fhandler_console::set_output_mode (tty::native,
+ fhandler_console::set_output_mode (conmode,
cons_ti, cons->get_handle_set ());
}
}
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-12 13:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-12 13:04 [PATCH 0/3] Fix behaviour of non-cygwin apps in background Takashi Yano
2021-12-12 13:04 ` [PATCH 1/3] Cygwin: pty: Fix Ctrl-C handling for " Takashi Yano
2021-12-12 13:05 ` [PATCH 2/3] Cygwin: pty: Fix console mode of " Takashi Yano
2021-12-12 13:05 ` [PATCH 3/3] Cygwin: console: " 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).