0

If I type stty -a on pts/0, it shows icanon among other flags, which is expected.

However, if I run stty from a terminal which is not the controlling terminal of the (bash) shell that I am currently in, it outputs -icanon. To summarize:

  • stty -a < /dev/pts/0 from pts/0, gives icanon, same as stty -a
  • stty -a < /dev/pts/0 from pts/1, gives -icanon
  • stty -a < /dev/pts/1 from pts/1, gives icanon, same as stty -a
  • stty -a < /dev/pts/1 from pts/0, gives -icanon

What's going on?

QnA
  • 515
  • 6
  • 16
  • I don't think you can redirect like that, but I haven't touched `stty` in many years. Maybe try [`--file=/dev/pts/0`](https://man7.org/linux/man-pages/man1/stty.1.html)? – Aaron D. Marasco Jun 16 '20 at 21:19
  • `--file=XXX` gives the same results. I think POSIX requires stty to use stdin anyways, so they are equivalent forms. – QnA Jun 16 '20 at 22:39
  • yes, that's basically the same question. – QnA Jun 17 '20 at 01:21

1 Answers1

3

Your terminal device's line discipline is not in canonical mode when the shell's command-line editor is active. When GNU Readline, ZLE, editline, or another command-line editing library is actively presenting its editor, the shell has switched the terminal line discipline to non-canonical mode. Think about it. Line editors, which have their own interpretations of control characters (including special characters) and which respond immediately as each character is typed, couldn't work any other way with terminal I/O.

Canonical mode is restored every time that the line editor finishes a line. Go to the first pseudoterminal, run an external command that runs for some length of time, such as sleep, and then see what is reported from the other pseudoterminal.

JdeBP
  • 66,967
  • 12
  • 159
  • 343
  • … and only now do I discover the duplicate at https://unix.stackexchange.com/q/226448/5132 . – JdeBP Jun 16 '20 at 23:39
  • OK, that would explain it. Does the bash shell line editor provide extra feature which the default canonical mode does not? – QnA Jun 17 '20 at 01:21