4

I have found two contradictory images of how a pseudo terminal (pty) works.

The first image shows that the process on the slave side of a pty talks to the line discipline:

enter image description here

The second image shows that the process on the slave side of a pty talks to the slave tty driver:

enter image description here

Which image is correct?

  • IMHO first digram seems wrong. Because the line terminal emulator suppose to be in between Hardware and process. in First image if you swap 'terminal line discipline' with 'pseudo terminal slave' it will be right. – Devidas May 30 '17 at 12:18
2

The second image is correct. (BTW, it comes from here.)

From the accepted answer on this question:

The line discipline is a software module (residing in the driver, in the kernel) pushed on top of a serial/pty device that sits between that device and the line/wire (the master side for a pty).

(...)

You can see the effect of disabling the tty line discipline by issuing stty raw -echo (note that the bash prompt or other interactive applications like vi set the terminal in the exact mode they need, so you want to use a dumb application like cat to experience with that). Then, everything that is written to the slave terminal device makes it immediately to the master side for xterm to read, and every character written by xterm to the master side is immediately available for reading from the slave device.

See also this post about ttys.

  • If the line discipline is on top of the underlying device, then the first image, which has exactly that, is the correct one. – JdeBP Aug 8 '17 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.