OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man4 / pts.4
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 2002-10-09 "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 is a character file with major number 5 and
15 minor number 2, usually of mode 0666 and owner.group of root.root.
16 It is used to create a pseudoterminal master and slave pair.
17 .PP
18 When a process opens
19 .IR /dev/ptmx ,
20 it gets a file
21 descriptor for a pseudoterminal master (PTM),
22 and a pseudoterminal slave (PTS) device is created in the
23 .I /dev/pts
24 directory.
25 Each file descriptor obtained by opening
26 .IR /dev/ptmx
27 is an independent PTM with its own associated PTS, whose path can
28 be found by passing the descriptor to
29 .BR ptsname (3).
30 .PP
31 Before opening the pseudoterminal slave, you must pass the master's file
32 descriptor to
33 .BR grantpt (3)
34 and
35 .BR unlockpt (3).
36 .PP
37 Once both the pseudoterminal master and slave are open, the slave provides
38 processes with an interface that is identical to that of a real terminal.
39 .PP
40 Data written to the slave is presented on the master descriptor as input.
41 Data written to the master is presented to the slave as input.
42 .PP
43 In practice, pseudoterminals are used for implementing terminal emulators
44 such as
45 .BR xterm (1),
46 in which data read from the pseudoterminal master is interpreted by the
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),
51 in which data read from the pseudoterminal master is sent across the network
52 to a client program that is connected to a terminal or terminal emulator.
53 .PP
54 Pseudoterminals can also be used to send input to programs that normally
55 refuse to read input from pipes (such as
56 .BR su (1),
57 and
58 .BR passwd (1)).
59 .SH FILES
60 .IR /dev/ptmx ,
61 .I /dev/pts/*
62 .SH NOTES
63 The Linux support for the above (known as UNIX 98 pseudoterminal naming)
64 is done using the
65 .I devpts
66 filesystem, that should be mounted on
67 .IR /dev/pts .
68 .LP
69 Before this UNIX 98 scheme, master pseudoterminals were called
70 .IR /dev/ptyp0 ", ..."
71 and slave pseudoterminals
72 .IR /dev/ttyp0 ", ..."
73 and one needed lots of preallocated device nodes.
74 .SH SEE ALSO
75 .BR getpt (3),
76 .BR grantpt (3),
77 .BR ptsname (3),
78 .BR unlockpt (3),
79 .BR pty (7)
80 .SH COLOPHON
81 This page is part of release 3.79 of the Linux
82 .I man-pages
83 project.
84 A description of the project,
85 information about reporting bugs,
86 and the latest version of this page,
87 can be found at
88 \%http://www.kernel.org/doc/man\-pages/.