1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (C) 2005 Michael Kerrisk <mtk.manpages@gmail.com>
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Japanese Version Copyright (c) 2005 Akihiro MOTOKI all rights reserved.
26 .\" Translated 2005-10-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
28 .\"WORD: pseudoterminal 擬似端末
29 .\"WORD: character device キャラクタデバイス
31 .TH PTY 7 2005-10-10 "Linux" "Linux Programmer's Manual"
34 .\"O pty \- pseudoterminal interfaces
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
45 .\"O the other end is called the
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
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
72 マスタ側に書き込まれた全てのデータは、スレーブ側のプロセスに送られる。
73 例えば、マスタデバイスに割り込みキャラクタ (通常は control-C) を書き込むと、
74 スレーブに接続されているフォアグラウンド・プロセスグループに対して
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,
88 .RB ( ssh "(1), " rlogin "(1), " telnet (1))
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
99 歴史的に見ると BSD と System V の2種類の擬似端末の API が発展してきている。
100 SUSv1 は System V API に基づいた擬似端末 API を標準化しており、
101 擬似端末を使用する新しいプログラムはすべてこの API を採用すべきである。
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"
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,
123 未使用の UNIX 98 擬似端末マスタをオープンするには
126 (この関数はマスタ・クローン・デバイス (master clone device),
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
143 を使ってスレーブデバイスの所有権や許可を変更し、
150 対応するスレーブデバイスをオープンできるようになる。
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
166 Linux カーネルでは、利用できる UNIX 98 擬似端末の数に上限を設けている。
167 2.6.3 以前のカーネルでは、この上限はカーネルのコンパイル時の設定
168 .RB ( CONFIG_UNIX98_PTYS )
169 である。許可される擬似端末の数は最大 2048 であり、
171 カーネル 2.6.4 以降では、この上限は
172 .I /proc/sys/kernel/pty/max
174 .I /proc/sys/kernel/pty/nr
179 .\"O .SS "BSD pseudoterminals"
181 .\"O BSD-style pseudoterminals are provided as precreated pairs, with
182 .\"O names of the form
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 風の擬似端末はあらかじめ作成されたペアとして提供される。その名前は
196 X は [p-za-e] の 16文字のうちの一文字、
197 Y は [0-9a-f] の 16文字のうちの一文字である
198 (X, Y に使われる文字の正確な範囲は UNIX の実装により異なる)。
203 .\"O constitute a BSD pseudoterminal pair.
209 .\"O A process finds an unused pseudoterminal pair by trying to
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 プロセスが未使用の擬似端末ペアを見つけるには、
217 を試み、open が成功するまでこれを繰り返す。
218 マスタを open すると、対応する擬似端末のスレーブも open できるようになる
219 (スレーブの名前は、マスタの名前の "pty" を "tty" に置き換えたものである)。
223 (UNIX 98 マスタ・クローン・デバイス)
228 .I /dev/pty[p-za-e][0-9a-f]
231 .I /dev/tty[p-za-e][0-9a-f]
235 .\"O A description of the
238 .\"O which controls packet mode operation, can be found in
239 .\"O .BR tty_ioctl (4).
255 .\"O have not been implemented under Linux.
263 はこれまでのところ Linux では実装されていない。