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

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.

Leave a Comment