1 .\" Copyright (C) 2002 Andries Brouwer <aeb@cwi.nl>
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" This replaces an earlier man page written by Walter Harms
24 .\" <walter.harms@informatik.uni-oldenburg.de>.
26 .\" Japanese Version Copyright (c) 2004 Yuichi SATO
27 .\" all rights reserved.
28 .\" Translated Wed Sep 8 01:25:01 JST 2004
29 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
31 .TH TTYSLOT 3 2010-09-20 "GNU" "Linux Programmer's Manual"
34 .\"O ttyslot \- find the slot of the current user's terminal in some file
35 ttyslot \- カレントユーザの端末のスロットをファイルから探す
38 .\"O .BR "#include <unistd.h>" " /* on BSD-like systems, and Linux */"
39 .BR "#include <unistd.h>" " /* BSD 系のシステムと Linux の場合 */"
41 .\"O .BR "#include <stdlib.h>" " /* on System V-like systems */"
42 .BR "#include <stdlib.h>" " /* System V 系のシステムの場合 */"
44 .B "int ttyslot(void);"
47 .\"O Feature Test Macro Requirements for glibc (see
48 .\"O .BR feature_test_macros (7)):
50 .RB ( feature_test_macros (7)
59 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_\ <\ 500\ &&\ _XOPEN_SOURCE_EXTENDED
64 .\"O The legacy function
66 .\"O returns the index of the current user's entry in some file.
69 は、あるファイルに書かれているカレントユーザのエントリのインデックスを返す。
71 .\"O Now "What file?" you ask.
72 .\"O Well, let's first look at some history.
73 「どのファイルなのか?」という質問があるだろう。
75 .\"O .SS "Ancient History"
77 .\"O There used to be a file
79 .\"O in UNIX V6, that was read by the
81 .\"O program to find out what to do with each terminal line.
88 .\"O Each line consisted of three characters.
90 .\"O The first character was either \(aq0\(aq or \(aq1\(aq,
91 .\"O where \(aq0\(aq meant "ignore".
92 1 文字目は \(aq0\(aq または \(aq1\(aq であり、
93 \(aq0\(aq は「無視する」ことを表す。
94 .\"O The second character denoted the terminal: \(aq8\(aq stood for "/dev/tty8".
95 2 文字目は端末を示す: \(aq8\(aq は "/dev/tty8" を表す。
96 .\"O The third character was an argument to
98 .\"O indicating the sequence of line speeds to try (\(aq\-\(aq was: start trying
100 .\"O Thus a typical line was "18\-".
103 への引き数であり、(接続を) 試みる回線速度の順序を表す
104 (\(aq\-\(aq は 110 ボーで接続の試行を開始することを表す)。
105 よって一般的な行は "18\-" となる。
106 .\"O A hang on some line was solved by changing the \(aq1\(aq to a \(aq0\(aq,
107 .\"O signaling init, changing back again, and signaling init again.
108 ある行でハングした場合は、\(aq1\(aq を \(aq0\(aq に変更し、
109 init にシグナルを送り、\(aq0\(aq を \(aq1\(aq 再度に変更し、
110 init に再度シグナルを送ることで解決する。
112 .\"O In UNIX V7 the format was changed: here the second character
113 .\"O was the argument to
115 .\"O indicating the sequence of line speeds to try (\(aq0\(aq was: cycle through
116 .\"O 300-1200-150-110 baud; \(aq4\(aq was for the on-line console DECwriter)
117 .\"O while the rest of the line contained the name of the tty.
118 .\"O Thus a typical line was "14console".
119 UNIX V7 ではフォーマットが変更された:
122 の引き数となり、(接続を) 試みる回線速度の順序を表すようになり
123 (\(aq0\(aq は 300-1200-150-110 を繰り返すことを表し、
124 \(aq4\(aq はオンラインコンソール DECwriter を表す)、
126 よって、一般的な行は "14console" となる。
128 .\"O Later systems have more elaborate syntax.
130 .\"O System V-like systems have
133 System V 系のシステムでは、代わりに
136 .\"O .SS "Ancient History (2)"
138 .\"O On the other hand, there is the file
140 .\"O listing the people currently logged in.
141 .\"O It is maintained by
143 一方、現在ログインしている人をリストするファイル
149 .\"O It has a fixed size, and the appropriate index in the file was
154 .\"O call to find the number of the line in
156 .\"O (counting from 1).
157 このファイルは固定されたサイズであり、ファイル内の適切なインデックスは、
164 における行番号を見つける (行番号は 1 から数える)。
165 .\"O .SS "The semantics of ttyslot"
167 .\"O Thus, the function
169 .\"O returns the index of the controlling terminal of the calling process
172 .\"O and that is (usually) the same as the index of the entry for the
173 .\"O current user in the file
179 における呼び出し元のプロセスの制御端末のインデックスを返す。
182 におけるカレントユーザのエントリのインデックスと (通常は) 等しい。
183 .\"O BSD still has the
185 .\"O file, but System V-like systems do not, and hence cannot refer to it.
188 ファイルがあるが、System V 系のシステムにはないので、
190 .\"O Thus, on such systems the documentation says that
192 .\"O returns the current user's index in the user accounting data base.
195 はカレントユーザのユーザアカウントデータベースにおけるインデックスを返す」
197 .\"O .SH "RETURN VALUE"
199 .\"O If successful, this function returns the slot number.
200 成功した場合、この関数はスロット番号を返す。
201 .\"O On error (e.g., if none of the file descriptors 0, 1 or 2 is
202 .\"O associated with a terminal that occurs in this data base)
203 .\"O it returns 0 on UNIX V6 and V7 and BSD-like systems,
204 .\"O but \-1 on System V-like systems.
206 (例えば、ファイルディスクリプタ 0, 1, 2 の何れも
207 データベースにある端末に関連づけられていない場合)、
208 UNIX V6, V7, BSD 系のシステムは 0 を返すが、
209 System V 系のシステムは -1 を返す。
210 .\"O .SH "CONFORMING TO"
212 .\"O SUSv1; marked as LEGACY in SUSv2; removed in POSIX.1-2001.
213 .\"O SUSv2 requires \-1 on error.
214 SUSv1。SUSv2 では「過去の名残 (LEGACY)」と位置付けられている。
216 SUSv2 ではエラー時に \-1 を返すことが要求されている。
219 .\"O The utmp file is found various places on various systems, such as
221 .\"O .IR /var/adm/utmp ,
222 .\"O .IR /var/run/utmp .
229 .\"O The glibc2 implementation of this function reads the file
230 .\"O .BR _PATH_TTYS ,
234 .\"O It returns 0 on error.
235 この関数の glibc2 における実装では、ファイル
240 において "/etc/ttys" と定義されている。
242 .\"O Since Linux systems do not usually have "/etc/ttys", it will
243 .\"O always return 0.
244 Linux システムには通常 "/etc/ttys" がないので、常に 0 を返す。
247 .\"O .IR fttyslot ( fd ).
253 .\"O .\" .BR ttyslot ()
254 .\"O .\" appeared in UNIX V7.