OSDN Git Service

6d6c64f65d23b996ec6b82b029be3a7e7a0bce81
[linuxjm/LDP_man-pages.git] / draft / man3 / openpty.3
1 .\" Copyright (c) OpenBSD Group
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\" Converted into a manpage again by Martin Schulze <joey@infodrom.org>
29 .\"
30 .\" Added -lutil remark, 030718
31 .\"
32 .\" Japanese Version Copyright (c) 2002 Yuichi SATO
33 .\"         all rights reserved.
34 .\" Translated Tue Jan 22 21:42:05 JST 2002
35 .\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
36 .\" Updated Mon Mar  8 2003 by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
37 .\" Updated Sun Sep 14 2003 by Akihiro MOTOKI
38 .\"
39 .\"WORD:        tty             端末
40 .\"WORD:        pseudoterminal  疑似端末
41 .\"
42 .TH OPENPTY 3  2010-06-13 "GNU" "Linux Programmer's Manual"
43 .\"O .SH NAME
44 .SH 名前
45 .\"O openpty, login_tty, forkpty \- tty utility functions
46 openpty, login_tty, forkpty \- 端末ユーティリティ関数
47 .\"O .SH SYNOPSIS
48 .SH 書式
49 .nf
50 .B #include <pty.h>
51 .sp
52 .BI "int openpty(int *" amaster ", int *" aslave ", char *" name ,
53 .BI "            const struct termios *" termp ,
54 .BI "            const struct winsize *" winp );
55 .sp
56 .BI "pid_t forkpty(int *" amaster ", char *" name ,
57 .BI "              const struct termios *" termp ,
58 .BI "              const struct winsize *" winp );
59 .sp
60 .B #include <utmp.h>
61 .sp
62 .BI "int login_tty(int " fd );
63 .sp
64 .\"O Link with \fI\-lutil\fP.
65 \fI\-lutil\fP でリンクする。
66 .fi
67 .\"O .SH DESCRIPTION
68 .SH 説明
69 .\"O The
70 .\"O .BR openpty ()
71 .\"O function finds an available pseudoterminal and returns file descriptors
72 .\"O for the master and slave in
73 .\"O .I amaster
74 .\"O and
75 .\"O .IR aslave .
76 .BR openpty ()
77 関数は、使用可能な疑似端末 (pseudoterminal) を見つけて、
78 マスタとスレーブのファイル・ディスクリプタを
79 .I amaster
80
81 .I aslave
82 に入れて返す。
83 .\"O If
84 .\"O .I name
85 .\"O is not NULL, the filename of the slave is returned in
86 .\"O .IR name .
87 .I name
88 が NULL でない場合、スレーブのファイル名が
89 .I name
90 に返される。
91 .\"O If
92 .\"O .I termp
93 .\"O is not NULL, the terminal parameters of the slave will be set to the
94 .\"O values in
95 .\"O .IR termp .
96 .I termp
97 が NULL でない場合、スレーブの端末パラメータは
98 .I termp
99 の値に設定される。
100 .\"O If
101 .\"O .I winp
102 .\"O is not NULL, the window size of the slave will be set to the values in
103 .\"O .IR winp .
104 .I winp
105 が NULL でない場合、スレーブのウインドウサイズは
106 .I winp
107 に設定される。
108
109 .\"O The
110 .\"O .BR login_tty ()
111 .\"O function prepares for a login on the tty
112 .\"O .I fd
113 .\"O (which may be a real tty device, or the slave of a pseudoterminal as
114 .\"O returned by
115 .\"O .BR openpty ())
116 .\"O by creating a new session, making
117 .\"O .I fd
118 .\"O the controlling terminal for the calling process, setting
119 .\"O .I fd
120 .\"O to be the standard input, output, and error streams of the current
121 .\"O process, and closing
122 .\"O .IR fd .
123 .BR login_tty ()
124 関数は、端末
125 .I fd
126 にログインする準備をする
127 .RI ( fd
128 は実際の端末デバイスでも、
129 .BR openpty ()
130 で返される疑似端末のスレーブでもよい)。
131 具体的には、新しいセッションを作成し、
132 .I fd
133 を呼び出し元のプロセスの制御端末とし、
134 呼び出し元の標準入力・標準出力・標準エラーのストリームを
135 .I fd
136 に設定した後、
137 .I fd
138 をクローズする。
139
140 .\"O The
141 .\"O .BR forkpty ()
142 .\"O function combines
143 .\"O .BR openpty (),
144 .\"O .BR fork (2),
145 .\"O and
146 .\"O .BR login_tty ()
147 .\"O to create a new process operating in a pseudoterminal.
148 .BR forkpty ()
149 関数は
150 .BR openpty (),
151 .BR fork (2),
152 .BR login_tty ()
153 を組み合わせ、疑似端末を操作する新しいプロセスを生成する。
154 .\"O The file
155 .\"O descriptor of the master side of the pseudoterminal is returned in
156 .\"O .IR amaster ,
157 .\"O and the filename of the slave in
158 .\"O .I name
159 .\"O if it is not NULL.
160 疑似端末のマスタ側のファイル・ディスクリプタは
161 .I amaster
162 に返され、
163 .I name
164 が NULL でない場合には、スレーブのファイル名が
165 .I name
166 に返される。
167 .\"O The
168 .\"O .I termp
169 .\"O and
170 .\"O .I winp
171 .\"O arguments, if not NULL,
172 .\"O will determine the terminal attributes and window size of the slave
173 .\"O side of the pseudoterminal.
174 .I termp
175
176 .I winp
177 引き数は、NULL でなければ、
178 疑似端末のスレーブ側の端末属性とウインドウサイズを決定する。
179 .\"O .SH "RETURN VALUE"
180 .SH 返り値
181 .\"O If a call to
182 .\"O .BR openpty (),
183 .\"O .BR login_tty (),
184 .\"O or
185 .\"O .BR forkpty ()
186 .\"O is not successful, \-1 is returned and
187 .\"O .I errno
188 .\"O is set to indicate the error.
189 .BR openpty (),
190 .BR login_tty (),
191 .BR forkpty ()
192 の呼び出しが成功しなかった場合、
193 \-1 が返されて、
194 .I errno
195 はエラーを示す値に設定される。
196 .\"O Otherwise,
197 .\"O .BR openpty (),
198 .\"O .BR login_tty (),
199 .\"O and the child process of
200 .\"O .BR forkpty ()
201 .\"O return 0, and the parent process of
202 .\"O .BR forkpty ()
203 .\"O returns the process ID of the child process.
204 成功した場合、
205 .BR openpty (),
206 .BR login_tty ()
207 および       
208 .BR forkpty ()
209 の子プロセスは 0 を返し、
210 .BR forkpty ()
211 の親プロセスは子プロセスのプロセス ID を返す。
212 .\"O .SH ERRORS
213 .SH エラー
214 .\"O .BR openpty ()
215 .\"O will fail if:
216 以下の場合に
217 .BR openpty ()
218 は失敗する:
219 .TP
220 .B ENOENT
221 .\"O There are no available ttys.
222 使用可能な端末がない。
223 .LP
224 .\"O .BR login_tty ()
225 .\"O will fail if
226 .\"O .BR ioctl (2)
227 .\"O fails to set
228 .\"O .I fd
229 .\"O to the controlling terminal of the calling process.
230 .BR ioctl (2)
231
232 .I fd
233 を呼び出し元のプロセスの制御端末に設定するのに失敗した場合、
234 .BR login_tty ()
235 は失敗する。
236 .LP
237 .\"O .BR forkpty ()
238 .\"O will fail if either
239 .\"O .BR openpty ()
240 .\"O or
241 .\"O .BR fork (2)
242 .\"O fails.
243 .BR openpty ()
244 または
245 .BR fork (2)
246 のどちらかが失敗した場合、
247 .BR forkpty ()
248 は失敗する。
249 .\"O .SH "CONFORMING TO"
250 .SH 準拠
251 .\"O These are BSD functions, present in libc5 and glibc2.
252 .\"O They are not standardized in POSIX.
253 これらは BSD の関数であり、libc5 と glibc2 に存在する。
254 POSIX での標準化はされていない。
255 .\"O .SH NOTES
256 .SH 注意
257 .\"O .\" These functions are included in libutil, hence you'll need to add
258 .\"O .\" .B \-lutil
259 .\"O .\" to your compiler command line.
260 .\" これらの関数は libutil に含まれている。したがって、コンパイル時の
261 .\" オプションに
262 .\" .B \-lutil
263 .\" を加える必要がある。
264 .\"
265 .\"O The
266 .\"O .B const
267 .\"O modifiers were added to the structure pointer arguments of
268 .\"O .BR openpty ()
269 .\"O and
270 .\"O .BR forkpty ()
271 .\"O in glibc 2.8.
272 glibc 2.8 で、
273 .BR openpty ()
274
275 .BR forkpty ()
276 の構造体へのポインタの引き数に
277 .B const
278 修飾子が追加された。
279
280 .\"O In versions of glibc before 2.0.92,
281 .\"O .BR openpty ()
282 .\"O returns file descriptors for a BSD pseudoterminal pair;
283 .\"O since glibc 2.0.92,
284 .\"O it first attempts to open a Unix 98 pseudoterminal pair,
285 .\"O and falls back to opening a BSD pseudoterminal pair if that fails.
286 2.0.92 より前のバージョンの glibc では、
287 .BR openpty ()
288 は BSD 疑似端末ペアのファイル・ディスクリプタを返す。
289 2.0.92 以降の glibc では、
290 .BR openpty ()
291 はまず Unix 98 疑似端末ペアをオープンしようとし、それに失敗した場合に
292 BSD 疑似端末ペアのオープンへと移行する。
293 .\"O .SH BUGS
294 .SH バグ
295 .\"O Nobody knows how much space should be reserved for
296 .\"O .IR name .
297 誰も
298 .I name
299 に対してどのくらい大きさを予約しておけばいいか分からない。
300 .\"O So, calling
301 .\"O .BR openpty ()
302 .\"O or
303 .\"O .BR forkpty ()
304 .\"O with non-NULL
305 .\"O .I name
306 .\"O may not be secure.
307 したがって、NULL でない
308 .I name
309 を引き数として
310 .BR openpty ()
311
312 .BR forkpty ()
313 を呼び出すのは安全であるとは言えない。
314 .\"O .SH "SEE ALSO"
315 .SH 関連項目
316 .BR fork (2),
317 .BR ttyname (3),
318 .BR pty (7)