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