Linux – Does the process on the slave side of a pty talks to the line discipline or to the slave tty driver

linuxpty

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?

Best Answer

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.