1PTY(7)                     Linux Programmer's Manual                    PTY(7)
2
3
4

NAME

6       pty - pseudoterminal interfaces
7

DESCRIPTION

9       A  pseudoterminal  (sometimes  abbreviated  "pty") is a pair of virtual
10       character devices that provide a bidirectional  communication  channel.
11       One  end  of  the channel is called the master; the other end is called
12       the slave.  The slave end of the pseudoterminal provides  an  interface
13       that behaves exactly like a classical terminal.  A process that expects
14       to be connected to a terminal, can open the slave end of a pseudotermi‐
15       nal  and  then  be  driven by a program that has opened the master end.
16       Anything that is written on the master end is provided to  the  process
17       on the slave end as though it was input typed on a terminal.  For exam‐
18       ple, writing the interrupt character (usually control-C) to the  master
19       device would cause an interrupt signal (SIGINT) to be generated for the
20       foreground process group that is connected to the  slave.   Conversely,
21       anything  that is written to the slave end of the pseudoterminal can be
22       read by the process that is connected to the master end.   Pseudotermi‐
23       nals  are  used by applications such as network login services (ssh(1),
24       rlogin(1), telnet(1)), terminal emulators such as xterm(1),  script(1),
25       screen(1), tmux(1), unbuffer(1), and expect(1).
26
27       Data flow between master and slave is handled asynchronously, much like
28       data flow with a physical terminal.  Data written to the slave will  be
29       available at the master promptly, but may not be available immediately.
30       Similarly, there may be a small processing delay between a write to the
31       master, and the effect being visible at the slave.
32
33       Historically,  two  pseudoterminal APIs have evolved: BSD and System V.
34       SUSv1 standardized a pseudoterminal API based on the System V API,  and
35       this  API  should be employed in all new programs that use pseudotermi‐
36       nals.
37
38       Linux provides both BSD-style and (standardized) System  V-style  pseu‐
39       doterminals.   System  V-style  terminals  are  commonly called UNIX 98
40       pseudoterminals on Linux systems.  Since kernel 2.6.4, BSD-style  pseu‐
41       doterminals  are  considered deprecated (they can be disabled when con‐
42       figuring the kernel); UNIX 98 pseudoterminals should  be  used  in  new
43       applications.
44
45   UNIX 98 pseudoterminals
46       An   unused   UNIX  98  pseudoterminal  master  is  opened  by  calling
47       posix_openpt(3).   (This  function  opens  the  master  clone   device,
48       /dev/ptmx; see pts(4).)  After performing any program-specific initial‐
49       izations, changing the ownership and permissions of  the  slave  device
50       using  grantpt(3), and unlocking the slave using unlockpt(3)), the cor‐
51       responding slave device can be opened by passing the name  returned  by
52       ptsname(3) in a call to open(2).
53
54       The  Linux  kernel  imposes  a limit on the number of available UNIX 98
55       pseudoterminals.  In kernels up to and including 2.6.3, this  limit  is
56       configured  at  kernel  compilation  time (CONFIG_UNIX98_PTYS), and the