.\" Copyright (c) OpenBSD Group .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" Converted into a manpage again by Martin Schulze .\" .\" Added -lutil remark, 030718 .\" .\" Japanese Version Copyright (c) 2002 Yuichi SATO .\" all rights reserved. .\" Translated Tue Jan 22 21:42:05 JST 2002 .\" by Yuichi SATO .\" Updated Mon Mar 8 2003 by Akihiro MOTOKI .\" Updated Sun Sep 14 2003 by Akihiro MOTOKI .\" .\"WORD: tty 端末 .\"WORD: pseudoterminal 疑似端末 .\" .TH OPENPTY 3 2010-06-13 "GNU" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O openpty, login_tty, forkpty \- tty utility functions openpty, login_tty, forkpty \- 端末ユーティリティ関数 .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "int openpty(int *" amaster ", int *" aslave ", char *" name , .BI " const struct termios *" termp , .BI " const struct winsize *" winp ); .sp .BI "pid_t forkpty(int *" amaster ", char *" name , .BI " const struct termios *" termp , .BI " const struct winsize *" winp ); .sp .B #include .sp .BI "int login_tty(int " fd ); .sp .\"O Link with \fI\-lutil\fP. \fI\-lutil\fP でリンクする。 .fi .\"O .SH DESCRIPTION .SH 説明 .\"O The .\"O .BR openpty () .\"O function finds an available pseudoterminal and returns file descriptors .\"O for the master and slave in .\"O .I amaster .\"O and .\"O .IR aslave . .BR openpty () 関数は、使用可能な疑似端末 (pseudoterminal) を見つけて、 マスタとスレーブのファイル・ディスクリプタを .I amaster と .I aslave に入れて返す。 .\"O If .\"O .I name .\"O is not NULL, the filename of the slave is returned in .\"O .IR name . .I name が NULL でない場合、スレーブのファイル名が .I name に返される。 .\"O If .\"O .I termp .\"O is not NULL, the terminal parameters of the slave will be set to the .\"O values in .\"O .IR termp . .I termp が NULL でない場合、スレーブの端末パラメータは .I termp の値に設定される。 .\"O If .\"O .I winp .\"O is not NULL, the window size of the slave will be set to the values in .\"O .IR winp . .I winp が NULL でない場合、スレーブのウインドウサイズは .I winp に設定される。 .\"O The .\"O .BR login_tty () .\"O function prepares for a login on the tty .\"O .I fd .\"O (which may be a real tty device, or the slave of a pseudoterminal as .\"O returned by .\"O .BR openpty ()) .\"O by creating a new session, making .\"O .I fd .\"O the controlling terminal for the calling process, setting .\"O .I fd .\"O to be the standard input, output, and error streams of the current .\"O process, and closing .\"O .IR fd . .BR login_tty () 関数は、端末 .I fd にログインする準備をする .RI ( fd は実際の端末デバイスでも、 .BR openpty () で返される疑似端末のスレーブでもよい)。 具体的には、新しいセッションを作成し、 .I fd を呼び出し元のプロセスの制御端末とし、 呼び出し元の標準入力・標準出力・標準エラーのストリームを .I fd に設定した後、 .I fd をクローズする。 .\"O The .\"O .BR forkpty () .\"O function combines .\"O .BR openpty (), .\"O .BR fork (2), .\"O and .\"O .BR login_tty () .\"O to create a new process operating in a pseudoterminal. .BR forkpty () 関数は .BR openpty (), .BR fork (2), .BR login_tty () を組み合わせ、疑似端末を操作する新しいプロセスを生成する。 .\"O The file .\"O descriptor of the master side of the pseudoterminal is returned in .\"O .IR amaster , .\"O and the filename of the slave in .\"O .I name .\"O if it is not NULL. 疑似端末のマスタ側のファイル・ディスクリプタは .I amaster に返され、 .I name が NULL でない場合には、スレーブのファイル名が .I name に返される。 .\"O The .\"O .I termp .\"O and .\"O .I winp .\"O arguments, if not NULL, .\"O will determine the terminal attributes and window size of the slave .\"O side of the pseudoterminal. .I termp と .I winp 引き数は、NULL でなければ、 疑似端末のスレーブ側の端末属性とウインドウサイズを決定する。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O If a call to .\"O .BR openpty (), .\"O .BR login_tty (), .\"O or .\"O .BR forkpty () .\"O is not successful, \-1 is returned and .\"O .I errno .\"O is set to indicate the error. .BR openpty (), .BR login_tty (), .BR forkpty () の呼び出しが成功しなかった場合、 \-1 が返されて、 .I errno はエラーを示す値に設定される。 .\"O Otherwise, .\"O .BR openpty (), .\"O .BR login_tty (), .\"O and the child process of .\"O .BR forkpty () .\"O return 0, and the parent process of .\"O .BR forkpty () .\"O returns the process ID of the child process. 成功した場合、 .BR openpty (), .BR login_tty () および .BR forkpty () の子プロセスは 0 を返し、 .BR forkpty () の親プロセスは子プロセスのプロセス ID を返す。 .\"O .SH ERRORS .SH エラー .\"O .BR openpty () .\"O will fail if: 以下の場合に .BR openpty () は失敗する: .TP .B ENOENT .\"O There are no available ttys. 使用可能な端末がない。 .LP .\"O .BR login_tty () .\"O will fail if .\"O .BR ioctl (2) .\"O fails to set .\"O .I fd .\"O to the controlling terminal of the calling process. .BR ioctl (2) が .I fd を呼び出し元のプロセスの制御端末に設定するのに失敗した場合、 .BR login_tty () は失敗する。 .LP .\"O .BR forkpty () .\"O will fail if either .\"O .BR openpty () .\"O or .\"O .BR fork (2) .\"O fails. .BR openpty () または .BR fork (2) のどちらかが失敗した場合、 .BR forkpty () は失敗する。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O These are BSD functions, present in libc5 and glibc2. .\"O They are not standardized in POSIX. これらは BSD の関数であり、libc5 と glibc2 に存在する。 POSIX での標準化はされていない。 .\"O .SH NOTES .SH 注意 .\"O .\" These functions are included in libutil, hence you'll need to add .\"O .\" .B \-lutil .\"O .\" to your compiler command line. .\" これらの関数は libutil に含まれている。したがって、コンパイル時の .\" オプションに .\" .B \-lutil .\" を加える必要がある。 .\" .\"O The .\"O .B const .\"O modifiers were added to the structure pointer arguments of .\"O .BR openpty () .\"O and .\"O .BR forkpty () .\"O in glibc 2.8. glibc 2.8 で、 .BR openpty () と .BR forkpty () の構造体へのポインタの引き数に .B const 修飾子が追加された。 .\"O In versions of glibc before 2.0.92, .\"O .BR openpty () .\"O returns file descriptors for a BSD pseudoterminal pair; .\"O since glibc 2.0.92, .\"O it first attempts to open a Unix 98 pseudoterminal pair, .\"O and falls back to opening a BSD pseudoterminal pair if that fails. 2.0.92 より前のバージョンの glibc では、 .BR openpty () は BSD 疑似端末ペアのファイル・ディスクリプタを返す。 2.0.92 以降の glibc では、 .BR openpty () はまず Unix 98 疑似端末ペアをオープンしようとし、それに失敗した場合に BSD 疑似端末ペアのオープンへと移行する。 .\"O .SH BUGS .SH バグ .\"O Nobody knows how much space should be reserved for .\"O .IR name . 誰も .I name に対してどのくらい大きさを予約しておけばいいか分からない。 .\"O So, calling .\"O .BR openpty () .\"O or .\"O .BR forkpty () .\"O with non-NULL .\"O .I name .\"O may not be secure. したがって、NULL でない .I name を引き数として .BR openpty () や .BR forkpty () を呼び出すのは安全であるとは言えない。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR fork (2), .BR ttyname (3), .BR pty (7)