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