PTY (7M) PTY (7M) NAME pty, pts -.. Pseudo terminal driver DESCRIPTION The pty driver provides a device-pair termed a pseudo terminal A pseudo terminal is a pair of character devices, a master device and a slave device The slave device provides processes an interface identical to that described in termio (7). However, whereas all other devices which provide the interface described in termio (7) 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. The following ioctl calls apply only to pseudo terminals:. TIOCPKT Enable / disable packet mode Packet mode is enabled by specifying (by reference) a nonzero parameter and disabled by specifying (by reference) a zero parameter When applied to the master side of a pseudo termin. al, each subsequent read from the terminal will return data written on the slave part of the pseudo terminal preceded by a zero byte (symbolically defined as TIOCPKT_DATA), or a single byte reflecting control status information. In the latter case, the byte is an Inclusive-or of zero or more of the bits:
TIOCPKT_FLUSHREAD whenever the read queue for the terminal is flushed. TIOCPKT_FLUSHWRITE whenever the write queue for the terminal is flushed. TIOCPKT_STOP whenever output to the terminal is stopped a la ^ S. TIOCPKT_START whenever output to the terminal is restarted. TIOCPKT_DOSTOP whenever t_stopc is ^ S And t_startc is ^ Q. Tiocpkt_nostop WHENEVER THE START and Stop Characters Are Not ^ S / ^ q. this mode is buy by rlogin (1c) and rlogind (1m) to import a remote-echoed, locally ^ s / ^ q Flow- controlled remote login with proper back-flushing of output; it can be used by other similar programs Page 1 PTY (7M) PTY (7M) ALLOCATION The code sequence shown below demonstrates how to allocate pseudo terminals pseudo terminals, like all files,.. Must Have The Correct File Permissions to Be Accessible. The __getpty (3) Library Function Takes Care of this Problem. #include
#include
/ * * Find a pseudo tty to use and open both sides. * Filedes [0] receives the master file descriptor while filedes [1] * receives the slave. The master is opened with O_NDELAY as commonly * needed in daemons such as rlogind and Telnetd. * / INT / * -1 ON Failure * / FindPseudotty (INT * filedes) {char * line; line = _getpty (& FileDes [0], o_rdwr | o_ndlay, 0600, 0); if (0 == line) Return -1; if (0> (FileDes [1] = Open (line, o_rdwr))) {(Void) Close (Filedes [0]); return -1;} return 0;} files / dev / ptc - master pseudo Terminal / dev / tty [qrstuvwxyz] [0-99] - SLAVE PSEUDO TERMINALS / DEV / PTS - Equivalent to / dev / Ttyq [0-9] See Also getPty (3)