2

When I run msys2.exe and launch a Python program, nothing gets printed to the terminal unless either enough text is printed such that the buffer automatically flushes, or if I run sys.stdout.flush().

In order to fix this, I have to launch msys2 with msys2_shell.cmd -defterm.

Defterm works fine in all ways, except for that it's really ugly. So, I'm hoping that there's a way to fix the mintty terminal such that it does not buffer output from my programs.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Jordan Epstein
  • 307
  • 4
  • 14
  • 1
    The terminal doesn't cause the buffering. mintty uses named pipes for standard I/O (stdin, stdout, stderr) as part of its emulation of a POSIX terminal and signals such as SIGTSTP for Ctrl+Z. This works well for other MSYS2 linked programs such as cat.exe. OTOH, python.exe is a Windows console application, which by default fully buffers its output if stdin is a pipe. – Eryk Sun May 01 '18 at 21:47
  • 3
    You can override this behavior with `python -i`, but Ctrl+Z will still be broken for `sys.stdin.read()`. A common workaround is to run `winpty python`, which let's Python use a hidden console (conhost.exe) while bridging to mintty. – Eryk Sun May 01 '18 at 21:49

0 Answers0