[PATCH v6 1/1] Cygwin: pty: add pseudo console support.

Thomas Wolff towo@towo.net
Tue Aug 13 21:14:00 GMT 2019


Am 12.08.2019 um 17:11 schrieb Takashi Yano:
> On Mon, 12 Aug 2019 15:44:05 +0200
> Thomas Wolff wrote:
>> I'd like to test your patch again, but if fails to apply to the current
>> master version for me.
>> Can you please tell us the commit (of newlib-cygwin/winsup) the patch is
>> based on, so it can simply be applied for testing?
> I confirmed this patch can be applied to:
> 744b90c9963cac8dbe62d8970f145e53b927d4e6
I've now retested conpty v6 and it has much improved since the previous 
version I tested, thank you very much.
The only 2 issues that I still observe are that character set conversion 
within a terminal is hard-targeted towards UTF-8, and one case of input 
stalling when using ReadConsole from a cygwin-compiled program.

Test results:

resize terminal while running Windows cmd
✓works
run cmd, run dir/P: works

signal handling/mediation
✓^Z is properly caught e.g. when running notepad

character set conversion from Windows cmd line program
✓works: xcopy (→ German error message)
↯non-ASCII output fails in non-Unicode mintty

The following cases refer to wincon.c, compiled with x86_64-w64-mingw32-gcc:
output: WriteConsoleW
✓works in Unicode mintty
↯non-ASCII output fails in non-Unicode mintty
output: SetConsoleTextAttribute character attributes
✓works
input: ReadConsoleW
✓works in Unicode mintty

The same program, compiled with cygwin gcc, fails in mintty:
output is skipped (like without the patch)
↯input stalls, kill -9 fails.
Without conpty patch v6, both output and input are skipped.
Note that winpty properly handles this case.

handling non-ASCII characters
↯fails in cmd within non-Unicode mintty (LC_ALL=en_US mintty)
(echo ö, or type file with a properly encoded ö)
but does not stall anymore...

terminal reports in response to request escape sequences
("\033[6n", "\033[0c", "\033[>c", '\033[18t', '\033]10;?\033\')
✓work

output to alternate screen
✓seems to work
before or while cmd.exe is running, echo "\033[?1047h" > /dev/pty...
to mintty from somewhere else, run dir...

-------------- next part --------------
#include <locale.h>
#include <wchar.h>
#include <stdio.h>
#include <windows.h>

void main()
{
  setlocale(LC_CTYPE, "");
  wchar_t * s = u"bäh 3€ 啕\n";
  HANDLE conout = GetStdHandle(STD_OUTPUT_HANDLE);
  DWORD len;

  printf("WriteConsole:\n");
  WriteConsoleW(conout, s, wcslen(s), &len, 0);

  printf("SetConsoleTextAttribute:\n");
  SetConsoleTextAttribute(conout, FOREGROUND_GREEN);
  WriteConsoleW(conout, s, wcslen(s), &len, 0);

  wchar_t buf[99];
  HANDLE conin = GetStdHandle(STD_INPUT_HANDLE);
  printf("ReadConsole:\n");
  ReadConsoleW(conin, buf, 9, &len, 0);
  buf[len] = 0;
  DWORD len1;
  WriteConsoleW(conout, buf, len, &len1, 0);
  printf("printf (%d chars): <%ls>\n", len, buf);
}


More information about the Cygwin-developers mailing list