issue #319: avoid TCSAFLUSH flag on WSL.

Closes #319.
This commit is contained in:
David Wilson 2018-07-27 02:31:34 +01:00
parent 56943d3141
commit 22bab87821
2 changed files with 11 additions and 4 deletions

View File

@ -79,6 +79,10 @@ Core Library
* `#307 <https://github.com/dw/mitogen/issues/307>`_: SSH login banner output
containing the word 'password' is no longer confused for a password prompt.
* `#319 <https://github.com/dw/mitogen/issues/319>`_: SSH connections would
fail immediately on Windows Subsystem for Linux, due to use of `TCSAFLUSH`
with :func:`termios.tcsetattr`. The flag is omitted if WSL is detected.
* Debug logs containing command lines are printed with the minimal quoting and
escaping required.

View File

@ -69,6 +69,8 @@ from mitogen.core import LOG
from mitogen.core import IOLOG
IS_WSL = 'Microsoft' in os.uname()[2]
if mitogen.core.PY3:
xrange = range
@ -125,10 +127,11 @@ def cfmakeraw(tflags):
def disable_echo(fd):
old = termios.tcgetattr(fd)
new = cfmakeraw(old)
flags = (
termios.TCSAFLUSH |
getattr(termios, 'TCSASOFT', 0)
)
flags = getattr(termios, 'TCSASOFT', 0)
if not IS_WSL:
# issue #319: Windows Subsystem for Linux as of July 2018 throws EINVAL
# if TCSAFLUSH is specified.
flags |= termios.TCSAFLUSH
termios.tcsetattr(fd, flags, new)