Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site bbncca.ARPA Path: utzoo!linus!bbncca!sdyer From: sdyer@bbncca.ARPA (Steve Dyer) Newsgroups: net.unix Subject: Re: pty.c in 4.1BSD ? Message-ID: <637@bbncca.ARPA> Date: Thu, 22-Mar-84 20:52:59 EST Article-I.D.: bbncca.637 Posted: Thu Mar 22 20:52:59 1984 Date-Received: Sat, 24-Mar-84 15:56:14 EST References: <140@vaxwalle.UUCP> Organization: Bolt, Beranek and Newman, Cambridge, Ma. Lines: 37 The pty driver is a hack to allow a user-mode process to present a TTY interface to another program. It was used by the old ARPAnet NCP Telnet protocol, and most recently by the 4.1BSD/BBN TCP/IP Telnet protocols. The model is as follows: ___________ _________________ | Network | <--> | Telnet Server | <---> /dev/ptcN :c:l:i:s:t:s /dev/ptyN <--> SH ----------- ----------------- Essentially, the telnet server reads characters from the network, and writes them to the PTY controller (here, /dev/ptcN.) This action is analogous to a DH or DZ interrupt routine, in that it puts characters on the terminal's input queue (here, the PTY "slave", /dev/ptyN). The user program (here, SH) will then receive them, by reading from its standard input. In the same way, when the user program writes to its standard output (also open on /dev/ptyN), the telnet server will be able to read those characters from the corresponding pty controller device, and then write them onto the network connection. This is roughly analogous to the "output interrupt" processing of a DH or DZ. The key is that this "server" can do anything it likes to the characters it reads or writes on the controller. Here, it is essentially a pass-thru (excepting the minor Telnet negotiations and protocol) serving merely to hook up a network connection to the UNIX model of a TTY. The PTY "slave" looks exactly like any TTY to the process which has it open, and indeed, one would usually enter such pseudo-TTY's into the /etc/ttys file. Virtual carrier is set when the corresponding controller device is opened. You could, instead, use the PTY's for anything you like, not necessarily a network. I once wrote a special filter for someone who had a DG "Dasher" terminal which went wild when it was sent ^H characters. We set her shell to read from a pseudo-TTY, and the process reading and writing on the controller mapped the characters appropriately. -- /Steve Dyer {decvax,linus,ima}!bbncca!sdyer sdyer@bbncca.ARPA