Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Figure 64-1 illustrates one of the problems that pseudoterminals help us solve: how can we enable a user on one host to operate a terminal-oriented program (e.g., vi) on another host connected via a network?
As shown in the diagram, by permitting communication over a network, sockets provide part of the machinery needed to solve this problem. However, we can’t connect the standard input, output, and error of a terminal-oriented program directly to a socket. This is because a terminal-oriented program expects to be connected to a terminal—to be able to perform the terminal-oriented operations described in Chapter 34 and Chapter 62. Such operations include placing the terminal in noncanonical mode, turning echoing on and off, and setting the terminal foreground process group. If a program tries to perform these operations on a socket, then the relevant system calls will fail.