Pty (7 m) Pty (7 m)
Name
Pty, PTS-pseudo do terminaldriver
Description
The Pty Driver provides a device-pair termed a Pseudo Terminal. apseudo
Terminal is a pair ROF character devices, amaster device and a slave
Device. The slavedevice providesprocesses an interface identical
That described in termio (7). However, whereas allother devices which
Provide the interface described intermio (7) have a hardware device
Some Sort behind them, theslave device has, instead, another process
Manipulating it through the masterhalf ofthe Pseudo Terminal. That is,
Anything written on the master device is given to the slave deviceas
Input and anythingwrittenon the slave device is presented as input on
The masterdevice.
The following IOCTL cballs apply only to pseudo terminals:
Tiocpkt
Enable/disable packetmode. packet mode is enabled by specifying
(By reference) a nonzero parameter and disabled by specifying (
Reference) a zero parameter. When applied tothe master sideof
Pseudo Terminal, eachsubsequent readfrom the terminal will return
Data written on the slave part of thepseudo terminalpreceded by
Zero byte (symbolically defined as tiocpkt_data), or a singlebyte
Reflecting control status information. In the lattercase, the byte
Is anqisive-or ofzero ormore ofthe bits:
Tiocpkt_flushread
Wheneverthe read queue for the terminateflushed.
Tiocpkt_flushwrite
Wheneverthe write queuefor theterminal is flushed.
Tiocpkt_stop
Wheneveroutput to the terminal is stopped a la ^ s.
Tiocpkt_start
Wheneveroutput to the terminal is restarted.
Tiocpkt_dostop
Whenevert_stopcis ^ s and t_startc is ^ Q.
Tiocpkt_nostop
Wheneverthe Start and Stop characters are not ^ s/^ Q.
This mode is used by rlogin (1C) and rlogind (1 m) to implement
Remote-echoed, locally ^ s/^ Q flow-controlled remote login
Proper back-flushing of output; it can be used by other similar
Programs.
Page 1
Pty (7 m) Pty (7 m)
Allocation
The code sequence shown below demonstrateshow to allocatepseudo
Terminals. pseudo terminals, likeall files, musthave the correct File
Permissions to be accessible. __ Getpty (3) library function takes care
Ofthis problem.
# Include
# Include
/*
* Find a pseudo tty to use and open both sides.
* Filedes [0] es the masterfile descriptorwhile filedes [1]
* Es the slave. The master is opened witho_ndelay as commonly
* Neededin daemons suchas rlogind and telnetd.
*/
INT/*-1 on failure */
Findpseudotty (int * filedes)
{
Char * line;
Line = _ getpty (& filedes [0], o_rdwr | o_ndelay, 0600, 0 );
If (0 = line)
Return-1;
If (0> (filedes [1] = open (line, o_rdwr ))){
(Void) Close (filedes [0]);
Return-1;
}
Return0;
}
Files
/Dev/PTC-master pseudo do Terminal
/Dev/tty [qrstuvwxyz] [0-99]-slave pseudo do Terminals
/Dev/PTS-equivalentto/dev/ttyq [0-9]
See also
Getpty (3)