WSL icon indicating copy to clipboard operation
WSL copied to clipboard

termios implementation is incomplete

Open cgull opened this issue 10 years ago • 10 comments

I suspect you already know most/all of this and somebody is feverishly working on this (and I don't envy them-- ttys are one of the ugliest parts of Unix kernels), but the termios implementation is missing a lot of things and seems to have bugs as well.

  • The ONLCR flag is not honored, and so programs reading text from the user on stdin will not advance the cursor to the next line correctly. This is a pretty significant bug.
  • In canonical mode, printable echo of control characters is weirdly broken. It appears that characters that termios expects to process are echoed printably, but others are echoed raw. Additionally, DEL (from the Backspace key) is echoed as ^�, where I suspect the raw character is DEL.
  • The QUIT character (usually ^\) does not seem to generate SIGQUIT, ever.
  • The INTR character (usually ^C) works, but can take a very long time to interrupt programs spewing text, such as cat /etc/ssh/moduli. This might be caused by excessive buffering on console output.
  • In general none of the canonical line-editing features seem to work.

I don't expect a full implementation of termios, especially if actual asynchronous serial ports will never be connected to this implementation-- but a significant subset of the canonical-mode processing will be needed for interactive programs that don't use readline or raw input.

cgull avatar Apr 13 '16 04:04 cgull

You are correct we have somebody feverishly working on fleshing out our tty and pty support :)

It's high on our list of things we know that we need to improve, your list will be super helpful for the dev who is working on this now - I'll make sure he sees this thread.

Thank for all the excellent feedback today!

benhillis avatar Apr 13 '16 04:04 benhillis

On 14361:

  • CR -> CR/LF echo on input seems correct now (I'd earlier described this as the ONLCR flag-- that's wrong, this is some other part of termio functionality).
  • Printable echo of control characters works well; so does erase of printed control characters
  • QUIT still does nothing
  • erase works, but none of the other line-editing features (kill, rprnt, werase, lnext) seem to work.
  • start/stop (XON/XOFF) don't function
  • INTR works rapidly on both conhost and ptys

There's still weirdness in the corners but this termios is a lot more usable.

cgull avatar Jun 09 '16 23:06 cgull

I am attempting to run a command line example from the OpenThread GitHub project and have found that the code that calls poll on STDIN isn't working.

The code waits on a number of inputs with a select call. That returns correctly when a key is pressed, but when it immediately calls poll, the function just returns 0. If I comment out the poll call and directly call read, that seems to return the correct result.

Is this a bug with BashOnWindows or does the code need to be adapted somehow to work in this environment?

nibanks avatar Aug 11 '16 17:08 nibanks

@nibanks - WSL does not currently respect the POLLRDNORM/POLLWRNORM bits. If you add POLLIN (in addition or in place of POLLRDNORM) you should see the expected results.

Brian-Perkins avatar Aug 11 '16 22:08 Brian-Perkins

Thanks, that worked! If you answer the StackOverflow question I posted on it, that might help any others who come across this.

nibanks avatar Aug 12 '16 15:08 nibanks

Thanks for the discussion.

Closing this issue since:

  1. Most of these issues are now fixed in recent Win10 builds
  2. This is the WSL issues repo, but this is an issue in Console which has its own Console GitHub Repo
  3. GitHub doesn't allow issues to be moved between repos, preserving posters' identity :(

If you have further asks/issues, please file new issues on our Console GitHub Repo.

bitcrazed avatar May 22 '18 22:05 bitcrazed

I don't have any problem with closing this, but you do support physical serial ports now-- is that supported in WSL, or in Console?

cgull avatar May 31 '18 03:05 cgull

@cgull - Access to serial port has been supported in WSL for sometime now. I am not sure what you mean by in Console?

sunilmut avatar May 31 '18 17:05 sunilmut

I think the question was whether the OP is a "in Console" tracker thing or a WSL thing. I am not sure this should have been marked label: console because terminios(3) things aren't directly related to your terminal emulator. Or, if you go to a garage sale, directly related to the real terminal connected to /dev/ttyS0. I have no idea if XON/XOFF or QUIT/SUSP/DSUSP works in WSL or not (on /dev/pts/* or /dev/ttyS0). If they don't, it would be best to open a new issue with a repro. Rich directed folks to the other tracker but I assume they should be opened here.

therealkenc avatar May 31 '18 20:05 therealkenc

Thanks as always @therealkenc for your help with this :)

@cgull WSL, and Windows Console (the default terminal/Console on Windows), have been significantly improved since your OP.

If you find further issues with the Console UX, or Windows' handling of tty/pty type scenarios, please file specific issues on https://github.com/microsoft/console/issues.

If you find further issues with WSL and its ability to run Linux binaries, or mimic Linux behaviors, please open new issues in this repo.

Many thanks for your continued support.

bitcrazed avatar Jun 12 '18 16:06 bitcrazed