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