Cygwin: pty: add pseudo console support.

- Support pseudo console in PTY. Pseudo console is a new feature
  in Windows 10 1809, which provides console APIs on virtual
  terminal. With this patch, native console applications can work
  in PTYs such as mintty, ssh, gnu screen or tmux.
This commit is contained in:
Takashi Yano
2019-08-28 03:04:02 +09:00
committed by Corinna Vinschen
parent 398476acd2
commit 169d65a577
12 changed files with 2016 additions and 55 deletions

View File

@@ -279,6 +279,30 @@ strace::vprntf (unsigned category, const char *func, const char *fmt, va_list ap
CloseHandle (h);
}
}
#if 1 /* Experimental code */
/* PTY with pseudo console cannot display data written to
STD_ERROR_HANDLE (output_handle) if the process is cygwin
process. output_handle works only in native console apps.
Therefore the data should be written to output_handle_cyg
as well. */
fhandler_base *fh = ::cygheap->fdtab[2];
if (fh && fh->get_major () == DEV_PTYS_MAJOR)
{
fhandler_pty_slave *ptys = (fhandler_pty_slave *) fh;
if (ptys->getPseudoConsole ())
{
HANDLE h_cyg = ptys->get_output_handle_cyg ();
if (buf[len-1] == '\n' && len < NT_MAX_PATH - 1)
{
buf[len-1] = '\r';
buf[len] = '\n';
len ++;
}
WriteFile (h_cyg, buf, len, &done, 0);
FlushFileBuffers (h_cyg);
}
}
#endif
}
#ifndef NOSTRACE