When terminal devices are in cooked mode, bytes input into terminal is cached and processed by kernel, some bytes are used for line editting and "cosumed", making read return one line a time.

But for pty, Output to master fd can be read as input from slave fd and vice versa, so my question is:

Do pty devices have two independent input buffers, unlike tty, one buffer per tty device?

  • The terminal driver can have its own buffers, which are not the same as the raw device's. Oct 3, 2018 at 9:19
  • @ThomasDickey That's not what I asked. TTY don't have master/slave concept. I want to know since pty can be read from either end (master/slave), does it have two input buffers? If no, then how does this master/slave functionality work? Oct 3, 2018 at 9:28

1 Answer 1


A pty behaves as a normal tty. A normal tty has input (raw and cooked mode) and output queues.

With a pty, the tty output queue is connected to master input and the tty raw input is connected to master output. So it's not that there are more queues, it's that you can regard the tty output queue as input from the master's side.


A pty is a normal tty. The generic tty part handles things like line editing, raw and cooked mode input, flow control like Ctrl+S and so on.

Every tty has a back end that handles actual input and output. This can be a serial driver. It can be the driver that interfaces with a keyboard and the VGA or frame buffer. It can also be a PTY master. In the case of a pty, the tty output is made available for the master to read, and the master writes are placed in the raw input queue.

  • I don't quite understand. " the tty output queque is…" When talking about pty, how is tty related? I want to know when read/write master/slave(4 combinations), which buffer am I touching? Oct 3, 2018 at 9:36
  • The phrase that will help here is terminal line discipline.
    – JdeBP
    Oct 3, 2018 at 11:20
  • @JdeBP that's the thing who process the raw input, referred as "the generic tty part" in this answer? Oct 3, 2018 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .