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.
This commit is contained in:
Takashi Yano
2020-08-19 20:25:21 +09:00
committed by Corinna Vinschen
parent b9261fa1d9
commit bb42852062
12 changed files with 340 additions and 1720 deletions

View File

@@ -94,21 +94,13 @@ private:
HANDLE _to_master;
HANDLE _to_master_cyg;
HPCON h_pseudo_console;
HANDLE h_helper_process;
DWORD helper_process_id;
HANDLE h_helper_goodbye;
bool attach_pcon_in_fork;
bool pcon_start;
bool switch_to_pcon_in;
bool switch_to_pcon_out;
bool screen_alternated;
bool mask_switch_to_pcon_in;
pid_t pcon_pid;
UINT term_code_page;
bool need_redraw_screen;
DWORD pcon_last_time;
bool pcon_in_empty;
bool req_transfer_input_to_pcon;
bool req_flush_pcon_input;
HANDLE h_pcon_write_pipe;
public:
HANDLE from_master () const { return _from_master; }
@@ -138,7 +130,6 @@ public:
void set_master_ctl_closed () {master_pid = -1;}
static void __stdcall create_master (int);
static void __stdcall init_session ();
void set_switch_to_pcon_out (bool v);
void wait_pcon_fwd (void);
friend class fhandler_pty_common;
friend class fhandler_pty_master;