OSDN Git Service

4c2c748fdbd5d37e5df8d80f1297066a50c701fc
[linuxjm/LDP_man-pages.git] / draft / man7 / pty.7
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (C) 2005 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .\" Japanese Version Copyright (c) 2005 Akihiro MOTOKI all rights reserved.
26 .\" Translated 2005-10-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
27 .\"
28 .\"WORD:        pseudoterminal          擬似端末
29 .\"WORD:        character device        キャラクタデバイス
30 .\"
31 .TH PTY 7 2005-10-10 "Linux" "Linux Programmer's Manual"
32 .\"O .SH NAME
33 .SH 名前
34 .\"O pty \- pseudoterminal interfaces
35 pty \- 擬似端末インタフェース
36 .\"O .SH DESCRIPTION
37 .SH 説明
38 .\"O A pseudoterminal (sometimes abbreviated "pty")
39 .\"O is a pair of virtual character devices that
40 .\"O provide a bidirectional communication channel.
41 擬似端末 (pseudoterminal; "pty" と略されることもある) は、
42 双方向通信チャンネルを提供する仮想キャラクタデバイスのペアである。
43 .\"O One end of the channel is called the
44 .\"O .IR master ;
45 .\"O the other end is called the
46 .\"O .IR slave .
47 チャンネルの一方の端点は
48 .I マスタ (master)
49 と呼ばれ、もう一方の端点は
50 .I スレーブ (slave)
51 と呼ばれる。
52 .\"O The slave end of the pseudoterminal provides an interface
53 .\"O that behaves exactly like a classical terminal.
54 .\"O A process that expects to be connected to a terminal,
55 .\"O can open the slave end of a pseudoterminal and
56 .\"O then be driven by a program that has opened the master end.
57 擬似端末のスレーブは、伝統的な端末と全く同じ動作をするインタフェースを
58 提供する。端末に接続されることを想定しているプロセスは擬似端末の
59 スレーブをオープンすることができ、それ以降はマスタ側をオープン
60 しているプログラムからそのプロセスを制御することができる。
61 .\"O Anything that is written on the master end is provided to the process
62 .\"O on the slave end as though it was input typed on a terminal.
63 .\"O For example, writing the interrupt character (usually control-C)
64 .\"O to the master device would cause an interrupt signal
65 .\"O .RB ( SIGINT )
66 .\"O to be generated for the foreground process group
67 .\"O that is connected to the slave.
68 .\"O Conversely, anything that is written to the slave end of the
69 .\"O pseudoterminal can be read by the process that is connected to
70 .\"O the master end.
71 端末で入力されたのと同じように、
72 マスタ側に書き込まれた全てのデータは、スレーブ側のプロセスに送られる。
73 例えば、マスタデバイスに割り込みキャラクタ (通常は control-C) を書き込むと、
74 スレーブに接続されているフォアグラウンド・プロセスグループに対して
75 割り込みシグナル
76 .RB ( SIGINT )
77 が生成される。
78 反対に、擬似端末のスレーブ側に書き込まれた全てのデータは、
79 マスタ側に接続されているプロセスから読み出すことができる。
80 .\"O Pseudoterminals are used by applications such as network login services
81 .\"O .RB ( ssh "(1), " rlogin "(1), " telnet (1)),
82 .\"O terminal emulators,
83 .\"O .BR script (1),
84 .\"O .BR screen (1),
85 .\"O and
86 .\"O .BR expect (1).
87 擬似端末は、ネットワークログインサービス
88 .RB ( ssh "(1), " rlogin "(1), " telnet (1))
89 や端末エミュレータ、
90 .BR script (1),
91 .BR screen (1),
92 .BR expect (1)
93 などのアプリケーションで使用されている。
94
95 .\"O Historically, two pseudoterminal APIs have evolved: BSD and System V.
96 .\"O SUSv1 standardized a pseudoterminal API based on the System V API,
97 .\"O and this API should be employed in all new programs that use
98 .\"O pseudoterminals.
99 歴史的に見ると BSD と System V の2種類の擬似端末の API が発展してきている。
100 SUSv1 は System V API に基づいた擬似端末 API を標準化しており、
101 擬似端末を使用する新しいプログラムはすべてこの API を採用すべきである。
102
103 .\"O Linux provides both BSD-style and (standardized) System V-style
104 .\"O pseudoterminals.
105 .\"O System V-style terminals are commonly called UNIX 98 pseudoterminals
106 .\"O on Linux systems.
107 .\"O Since kernel 2.6.4, BSD-style pseudoterminals are considered deprecated
108 .\"O (they can be disabled when configuring the kernel);
109 .\"O UNIX 98 pseudoterminals should be used in new applications.
110 Linux では BSD 風と (標準化された) System V 風の擬似端末を提供している。
111 System V 風の端末は、Linux システムでは一般に UNIX 98 擬似端末と呼ばれている。
112 カーネル 2.6.4 以降では、BSD 風の擬似端末は廃止予定とみなされている
113 (カーネルのコンフィギュレーションで BSD 風の擬似端末を無効にすることができる)。
114 新しいアプリケーションでは、UNIX 98 擬似端末を使用すべきである。
115 .\"O .SS "UNIX 98 pseudoterminals"
116 .SS "UNIX 98 擬似端末"
117 .\"O An unused UNIX 98 pseudoterminal master is opened by calling
118 .\"O .BR posix_openpt (3).
119 .\"O (This function opens the master clone device,
120 .\"O .IR /dev/ptmx ;
121 .\"O see
122 .\"O .BR pts (4).)
123 未使用の UNIX 98 擬似端末マスタをオープンするには
124 .BR posix_openpt (3)
125 を呼び出す
126 (この関数はマスタ・クローン・デバイス (master clone device),
127 .I /dev/ptmx
128 をオープンする;
129 .BR pts (4)
130 を参照)。
131 .\"O After performing any program-specific initializations,
132 .\"O changing the ownership and permissions of the slave device using
133 .\"O .BR grantpt (3),
134 .\"O and unlocking the slave using
135 .\"O .BR unlockpt (3)),
136 .\"O the corresponding slave device can be opened by passing
137 .\"O the name returned by
138 .\"O .BR ptsname (3)
139 .\"O in a call to
140 .\"O .BR open (2).
141 プログラム固有の初期化処理を実行し、
142 .BR grantpt (3)
143 を使ってスレーブデバイスの所有権や許可を変更し、
144 .BR unlockpt (3)
145 を使ってスレーブのロック解除を行うと、
146 .BR ptsname (3)
147 が返す名前を渡して
148 .BR open (2)
149 を呼び出すことにより
150 対応するスレーブデバイスをオープンできるようになる。
151
152 .\"O The Linux kernel imposes a limit on the number of available
153 .\"O UNIX 98 pseudoterminals.
154 .\"O In kernels up to and including 2.6.3, this limit is configured
155 .\"O at kernel compilation time
156 .\"O .RB ( CONFIG_UNIX98_PTYS ),
157 .\"O and the permitted number of pseudoterminals can be up to 2048,
158 .\"O with a default setting of 256.
159 .\"O Since kernel 2.6.4, the limit is dynamically adjustable via
160 .\"O .IR /proc/sys/kernel/pty/max ,
161 .\"O and a corresponding file,
162 .\"O .IR /proc/sys/kernel/pty/nr ,
163 .\"O indicates how many pseudoterminals are currently in use.
164 .\"O For further details on these two files, see
165 .\"O .BR proc (5).
166 Linux カーネルでは、利用できる UNIX 98 擬似端末の数に上限を設けている。
167 2.6.3 以前のカーネルでは、この上限はカーネルのコンパイル時の設定
168 .RB ( CONFIG_UNIX98_PTYS )
169 である。許可される擬似端末の数は最大 2048 であり、
170 デフォルトの設定は 256 である。
171 カーネル 2.6.4 以降では、この上限は
172 .I /proc/sys/kernel/pty/max
173 経由で動的に調整可能となっている。また、
174 .I /proc/sys/kernel/pty/nr
175 で現在使用中の擬似端末の数を取得できる。
176 この 2つのファイルの詳細は
177 .BR proc (5)
178 を参照。
179 .\"O .SS "BSD pseudoterminals"
180 .SS "BSD 擬似端末"
181 .\"O BSD-style pseudoterminals are provided as precreated pairs, with
182 .\"O names of the form
183 .\"O .I /dev/ptyXY
184 .\"O (master) and
185 .\"O .I /dev/ttyXY
186 .\"O (slave),
187 .\"O where X is a letter from the 16-character set [p-za-e],
188 .\"O and Y is a letter from the 16-character set [0-9a-f].
189 .\"O (The precise range of letters in these two sets varies across UNIX
190 .\"O implementations.)
191 BSD 風の擬似端末はあらかじめ作成されたペアとして提供される。その名前は
192 .I /dev/ptyXY
193 (マスタ側)、
194 .I /dev/ttyXY
195 (スレーブ側) である。ここで、
196 X は [p-za-e] の 16文字のうちの一文字、
197 Y は [0-9a-f] の 16文字のうちの一文字である
198 (X, Y に使われる文字の正確な範囲は UNIX の実装により異なる)。
199 .\"O For example,
200 .\"O .I /dev/ptyp1
201 .\"O and
202 .\"O .I /dev/ttyp1
203 .\"O constitute a BSD pseudoterminal pair.
204 例えば、
205 .I /dev/ptyp1
206
207 .I /dev/ttyp1
208 は BSD 擬似端末ペアを構成する。
209 .\"O A process finds an unused pseudoterminal pair by trying to
210 .\"O .BR open (2)
211 .\"O each pseudoterminal master until an open succeeds.
212 .\"O The corresponding pseudoterminal slave (substitute "tty"
213 .\"O for "pty" in the name of the master) can then be opened.
214 プロセスが未使用の擬似端末ペアを見つけるには、
215 各擬似端末のマスタの
216 .BR open (2)
217 を試み、open が成功するまでこれを繰り返す。
218 マスタを open すると、対応する擬似端末のスレーブも open できるようになる
219 (スレーブの名前は、マスタの名前の "pty" を "tty" に置き換えたものである)。
220 .\"O .SH "FILES"
221 .SH ファイル
222 .I /dev/ptmx
223 (UNIX 98 マスタ・クローン・デバイス)
224 .br
225 .I /dev/pts/*
226 (UNIX 98 スレーブデバイス)
227 .br
228 .I /dev/pty[p-za-e][0-9a-f]
229 (BSD マスタデバイス)
230 .br
231 .I /dev/tty[p-za-e][0-9a-f]
232 (BSD スレーブデバイス)
233 .\"O .SH "NOTES"
234 .SH 注意
235 .\"O A description of the
236 .\"O .B TIOCPKT
237 .\"O .BR ioctl (2),
238 .\"O which controls packet mode operation, can be found in
239 .\"O .BR tty_ioctl (4).
240 パケット・モード操作の制御を行う
241 .B TIOCPKT
242 .BR ioctl (2)
243 の説明は
244 .BR tty_ioctl (4)
245 に書かれている。
246
247 .\"O The BSD
248 .\"O .BR ioctl (2)
249 .\"O operations
250 .\"O .BR TIOCSTOP ,
251 .\"O .BR TIOCSTART ,
252 .\"O .BR TIOCUCNTL ,
253 .\"O and
254 .\"O .BR TIOCREMOTE
255 .\"O have not been implemented under Linux.
256 BSD
257 .BR ioctl (2)
258
259 .BR TIOCSTOP ,
260 .BR TIOCSTART ,
261 .BR TIOCUCNTL ,
262 .B TIOCREMOTE
263 はこれまでのところ Linux では実装されていない。
264 .\"O .SH "SEE ALSO"
265 .SH 関連項目
266 .BR select (2),
267 .BR setsid (2),
268 .BR forkpty (3),
269 .BR openpty (3),
270 .BR termios (3),
271 .BR pts (4),
272 .BR tty (4),
273 .BR tty_ioctl (4)