Skip to content

Commit

Permalink
Cygwin: pty: Inherit typeahead data between two input pipes.
Browse files Browse the repository at this point in the history
- PTY has a problem that the key input, which is typed during
  windows native app is running, disappear when it returns to shell.
  (Problem 3 in https://cygwin.com/ml/cygwin/2020-02/msg00007.html)
  This is beacuse pty has two input pipes, one is for cygwin apps
  and the other one is for native windows apps. The key input during
  windows native program is running is sent to the second input pipe
  while cygwin shell reads input from the first input pipe.
  This patch realize transfering input data between these two pipes.
  • Loading branch information
tyan0 authored and github-cygwin committed Feb 10, 2020
1 parent a4ca6c4 commit 29431fc
Show file tree
Hide file tree
Showing 5 changed files with 329 additions and 91 deletions.
12 changes: 9 additions & 3 deletions winsup/cygwin/fhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class fhandler_base
virtual size_t &raixput () { return ra.raixput; };
virtual size_t &rabuflen () { return ra.rabuflen; };

bool get_readahead_valid () { return raixget () < ralen (); }
virtual bool get_readahead_valid () { return raixget () < ralen (); }
int puts_readahead (const char *s, size_t len = (size_t) -1);
int put_readahead (char value);

Expand All @@ -335,7 +335,7 @@ class fhandler_base

void set_readahead_valid (int val, int ch = -1);

int get_readahead_into_buffer (char *buf, size_t buflen);
virtual int get_readahead_into_buffer (char *buf, size_t buflen);

bool has_acls () const { return pc.has_acls (); }

Expand Down Expand Up @@ -1768,7 +1768,7 @@ class fhandler_termios: public fhandler_base
int ioctl (int, void *);
tty_min *_tc;
tty *get_ttyp () {return (tty *) tc ();}
int eat_readahead (int n);
virtual int eat_readahead (int n);

public:
tty_min*& tc () {return _tc;}
Expand Down Expand Up @@ -2168,6 +2168,9 @@ class fhandler_pty_slave: public fhandler_pty_common
ssize_t __stdcall write (const void *ptr, size_t len);
void __reg3 read (void *ptr, size_t& len);
int init (HANDLE, DWORD, mode_t);
int eat_readahead (int n);
int get_readahead_into_buffer (char *buf, size_t buflen);
bool get_readahead_valid (void);

int tcsetattr (int a, const struct termios *t);
int tcgetattr (struct termios *t);
Expand Down Expand Up @@ -2217,6 +2220,8 @@ class fhandler_pty_slave: public fhandler_pty_common
void set_freeconsole_on_close (bool val);
void trigger_redraw_screen (void);
void wait_pcon_fwd (void);
void pull_pcon_input (void);
void update_pcon_input_state (bool need_lock);
};

#define __ptsname(buf, unit) __small_sprintf ((buf), "/dev/pty%d", (unit))
Expand Down Expand Up @@ -2281,6 +2286,7 @@ class fhandler_pty_master: public fhandler_pty_common
}

bool setup_pseudoconsole (void);
void transfer_input_to_pcon (void);
};

class fhandler_dev_null: public fhandler_base
Expand Down
Loading

0 comments on commit 29431fc

Please sign in to comment.