aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/fhandler_console.cc
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2020-08-19 20:25:21 +0900
committerCorinna Vinschen <corinna@vinschen.de>2020-08-22 13:43:49 +0200
commitbb4285206207343984d975f735d15701fd3ed6e1 (patch)
tree9135f702632e1757d5043aa01af9dcdd39eb2a94 /winsup/cygwin/fhandler_console.cc
parentb9261fa1d97df14d57699c4c903cacefb48681fb (diff)
downloadnewlib-bb4285206207343984d975f735d15701fd3ed6e1.zip
newlib-bb4285206207343984d975f735d15701fd3ed6e1.tar.gz
newlib-bb4285206207343984d975f735d15701fd3ed6e1.tar.bz2
Cygwin: pty: Implement new pseudo console support.
- In this implementation, pseudo console is created for each native console app. Advantages and disadvantages of this implementation over the previous implementation are as follows. Advantages: 1) No performance degradation in pty output for cygwin process. https://cygwin.com/pipermail/cygwin/2020-February/243858.html 2) Free from the problem caused by difference of behaviour of control sequences between real terminal and pseudo console. https://cygwin.com/pipermail/cygwin/2019-December/243281.html https://cygwin.com/pipermail/cygwin/2020-February/243855.html 3) Free from the problem in cgdb and emacs gud. https://cygwin.com/pipermail/cygwin/2020-January/243601.html https://cygwin.com/pipermail/cygwin/2020-March/244146.html 4) Redrawing screen on executing native console apps is not necessary. 5) cygwin-console-helper is not necessary for the pseudo console support. 6) The codes for pseudo console support are much simpler than that of the previous one. Disadvantages: 1) The cygwin program which calls console API directly does not work. 2) The apps which use console API cannot be debugged with gdb. This is because pseudo console is not activated since gdb uses CreateProcess() rather than exec(). Even with this limitation, attaching gdb to native apps, in which pseudo console is already activated, works. 3) Typeahead key inputs are discarded while native console app is executed. Simirally, typeahead key inputs while cygwin app is executed are not inherited to native console app. 4) Code page cannot be changed by chcp.com. Acctually, chcp works itself and changes code page of its own pseudo console. However, since pseudo console is recreated for another process, it cannot inherit the code page. 5) system_printf() does not work after stderr is closed. (Same with cygwin 3.0.7) 6) Startup time of native console apps is about 3 times slower than previous implemenation. 7) Pseudo console cannot be activated if it is already activated for another process on same pty.
Diffstat (limited to 'winsup/cygwin/fhandler_console.cc')
-rw-r--r--winsup/cygwin/fhandler_console.cc43
1 files changed, 0 insertions, 43 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 52741ce..02a5996 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -1206,18 +1206,6 @@ fhandler_console::close ()
if (con_ra.rabuf)
free (con_ra.rabuf);
- /* If already attached to pseudo console, don't call free_console () */
- cygheap_fdenum cfd (false);
- while (cfd.next () >= 0)
- if (cfd->get_major () == DEV_PTYM_MAJOR ||
- cfd->get_major () == DEV_PTYS_MAJOR)
- {
- fhandler_pty_common *t =
- (fhandler_pty_common *) (fhandler_base *) cfd;
- if (get_console_process_id (t->get_helper_process_id (), true))
- return 0;
- }
-
if (!have_execed)
free_console ();
return 0;
@@ -3612,37 +3600,6 @@ fhandler_console::need_invisible ()
}
DWORD
-fhandler_console::get_console_process_id (DWORD pid, bool match)
-{
- DWORD tmp;
- DWORD num, num_req;
- num = 1;
- num_req = GetConsoleProcessList (&tmp, num);
- DWORD *list;
- while (true)
- {
- list = (DWORD *)
- HeapAlloc (GetProcessHeap (), 0, num_req * sizeof (DWORD));
- num = num_req;
- num_req = GetConsoleProcessList (list, num);
- if (num_req > num)
- HeapFree (GetProcessHeap (), 0, list);
- else
- break;
- }
- num = num_req;
-
- tmp = 0;
- for (DWORD i=0; i<num; i++)
- if ((match && list[i] == pid) || (!match && list[i] != pid))
- /* Last one is the oldest. */
- /* https://github.com/microsoft/terminal/issues/95 */
- tmp = list[i];
- HeapFree (GetProcessHeap (), 0, list);
- return tmp;
-}
-
-DWORD
fhandler_console::__acquire_input_mutex (const char *fn, int ln, DWORD ms)
{
#ifdef DEBUGGING