Cygwin: pty: Fix select() with pseudo console support.

- select() did not work correctly when both read and except are
  polled simultaneously for the same fd and the r/w pipe is switched
  to pseudo console side. This patch fixes this isseu.
This commit is contained in:
Takashi Yano
2019-09-05 13:22:54 +09:00
committed by Corinna Vinschen
parent 433c6b8e0a
commit 915fcd0ae8
4 changed files with 207 additions and 15 deletions

View File

@@ -2102,6 +2102,7 @@ class fhandler_pty_common: public fhandler_termios
{
return get_ttyp ()->hPseudoConsole;
}
bool to_be_read_from_pcon (void);
protected:
BOOL process_opost_output (HANDLE h,
@@ -2150,6 +2151,8 @@ class fhandler_pty_slave: public fhandler_pty_common
void fixup_after_exec ();
select_record *select_read (select_stuff *);
select_record *select_write (select_stuff *);
select_record *select_except (select_stuff *);
virtual char const *ttyname () { return pc.dev.name (); }
int __reg2 fstat (struct stat *buf);
int __reg3 facl (int, int, struct acl *);
@@ -2177,9 +2180,21 @@ class fhandler_pty_slave: public fhandler_pty_common
void push_to_pcon_screenbuffer (const char *ptr, size_t len);
void mask_switch_to_pcon (bool mask)
{
if (!mask && get_ttyp ()->pcon_pid &&
get_ttyp ()->pcon_pid != myself->pid &&
kill (get_ttyp ()->pcon_pid, 0) == 0)
return;
get_ttyp ()->mask_switch_to_pcon = mask;
}
void fixup_after_attach (bool native_maybe);
pid_t get_pcon_pid (void)
{
return get_ttyp ()->pcon_pid;
}
bool is_line_input (void)
{
return get_ttyp ()->ti.c_lflag & ICANON;
}
};
#define __ptsname(buf, unit) __small_sprintf ((buf), "/dev/pty%d", (unit))