How do *nix pseudo-terminals work ? What's the master/slave channel?

前端 未结 2 1712
感情败类
感情败类 2020-12-01 04:30

I want to write a simple, dumb, X terminal emulator in C on a Linux system.

At first, I just thought I would have to popen a shell and display its output. I checked

2条回答
  •  伪装坚强ぢ
    2020-12-01 05:10

    With respect to the master/slave part of your question, from the pty(4) man page (which is referenced from the openpty(3) man page on my system):

    A pseudo terminal is a pair of character devices, a master device and a slave device. The slave device provides to a process an interface identical to that described in tty(4). However, whereas all other devices which provide the interface described in tty(4) have a hardware device of some sort behind them, the slave device has, instead, another process manipulating it through the master half of the pseudo terminal. That is, anything written on the master device is given to the slave device as input and anything written on the slave device is presented as input on the master device.

    Man pages are your friends.

提交回复
热议问题