This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cygwin 3.3.0: The programs compiled with "-mwindows" cannot read more than one byte from noncanonical mode TTY

2020年1月21日(火) 10:47 Takashi Yano <>:
> Thanks for the report. I could reproduce the problem under LANG=ja_JP.UTF-8.
> I have almost caught the culprit. Please wait for a while.

Thank you for the patch fixing the problem. I cherry-picked the patch
and tried it, but there is another problem.


  The programs compiled with "-mwindows" cannot read more than one
  character from PTY in a non-canonical mode in .  There was no
  problem before the patch "Cygwin: pty: Fix reopening slave in


  1. Open Cygwin Terminal (mintty)

  2. Compile the attached program with the following commands.

    $ g++ -o minimal2-con.exe minimal2.cpp
    $ g++ -mwindows -o minimal2-win.exe minimal2.cpp

  3. The expected behavior can be checked with `minimal2-con'.  After
    executing the command, please type some five characters.  The
    string `[RECV]' will be printed five times, and then the program
    will exit.

    $ ./minimal2-con

  4. However, with the compile option "-mwindows", we can only see one
    `[RECV]', and the program will hang.

    $ ./minimal2-win


#include <unistd.h>
#include <termios.h>

int main() {
  struct termios oldTermios;
  tcgetattr(STDIN_FILENO, &oldTermios);

  struct termios termios = oldTermios;
  termios.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
  termios.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
  termios.c_cflag &= ~(CSIZE | PARENB);
  termios.c_cflag |= CS8;
  termios.c_oflag &= ~(OPOST);
  termios.c_cc[VMIN]  = 1;
  termios.c_cc[VTIME] = 0;
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &termios);

  for (int i = 0; i < 5; i++) {
    char c;
    int const nread = read(STDIN_FILENO, &c, 1);
    write(STDOUT_FILENO, nread > 0 ? "[RECV]" : "[FAIL]", 6);
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &oldTermios);
  write(STDOUT_FILENO, "\n", 1);
  return 0;
Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]