mount_setattr.2: SEE ALSO: place entries in correct order
[man-pages.git] / man4 / pts.4
blob73e2a80ec9334f27717bd2d2b90a327ba4e4cd6d
1 .\" This man page was written by Jeremy Phelps <jphelps@notreached.net>.
2 .\" Notes added - aeb
3 .\"
4 .\" %%%LICENSE_START(FREELY_REDISTRIBUTABLE)
5 .\" Redistribute and revise at will.
6 .\" %%%LICENSE_END
7 .\"
8 .TH PTS 4 2020-08-13 "Linux" "Linux Programmer's Manual"
9 .SH NAME
10 ptmx, pts \- pseudoterminal master and slave
11 .SH DESCRIPTION
12 The file
13 .I /dev/ptmx
14 (the pseudoterminal multiplexor device)
15 is a character file with major number 5 and
16 minor number 2, usually with mode 0666 and ownership root:root.
17 It is used to create a pseudoterminal master and slave pair.
18 .PP
19 When a process opens
20 .IR /dev/ptmx ,
21 it gets a file
22 descriptor for a pseudoterminal master
23 and a pseudoterminal slave device is created in the
24 .I /dev/pts
25 directory.
26 Each file descriptor obtained by opening
27 .IR /dev/ptmx
28 is an independent pseudoterminal master with its own associated slave,
29 whose path can
30 be found by passing the file descriptor to
31 .BR ptsname (3).
32 .PP
33 Before opening the pseudoterminal slave, you must pass the master's file
34 descriptor to
35 .BR grantpt (3)
36 and
37 .BR unlockpt (3).
38 .PP
39 Once both the pseudoterminal master and slave are open, the slave provides
40 processes with an interface that is identical to that of a real terminal.
41 .PP
42 Data written to the slave is presented on the master file descriptor as input.
43 Data written to the master is presented to the slave as input.
44 .PP
45 In practice, pseudoterminals are used for implementing terminal emulators
46 such as
47 .BR xterm (1),
48 in which data read from the pseudoterminal master is interpreted by the
49 application in the same way
50 a real terminal would interpret the data, and for implementing remote-login
51 programs such as
52 .BR sshd (8),
53 in which data read from the pseudoterminal master is sent across the network
54 to a client program that is connected to a terminal or terminal emulator.
55 .PP
56 Pseudoterminals can also be used to send input to programs that normally
57 refuse to read input from pipes (such as
58 .BR su (1),
59 and
60 .BR passwd (1)).
61 .SH FILES
62 .IR /dev/ptmx ,
63 .I /dev/pts/*
64 .SH NOTES
65 The Linux support for the above (known as UNIX 98 pseudoterminal naming)
66 is done using the
67 .I devpts
68 filesystem, which should be mounted on
69 .IR /dev/pts .
70 .SH SEE ALSO
71 .BR getpt (3),
72 .BR grantpt (3),
73 .BR ptsname (3),
74 .BR unlockpt (3),
75 .BR pty (7)