OSDN Git Service

00bd944c34ca01bce23a4778ed187a95bcd561bb
[linuxjm/LDP_man-pages.git] / draft / man3 / ttyslot.3
1 .\" Copyright (C) 2002 Andries Brouwer <aeb@cwi.nl>
2 .\"
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.
6 .\"
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.
11 .\"
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
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" This replaces an earlier man page written by Walter Harms
24 .\" <walter.harms@informatik.uni-oldenburg.de>.
25 .\"
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>
30 .\"
31 .TH TTYSLOT 3 2010-09-20 "GNU" "Linux Programmer's Manual"
32 .\"O .SH NAME
33 .SH 名前
34 .\"O ttyslot \- find the slot of the current user's terminal in some file
35 ttyslot \- カレントユーザの端末のスロットをファイルから探す
36 .\"O .SH SYNOPSIS
37 .SH 書式
38 .\"O .BR "#include <unistd.h>"       "    /* on BSD-like systems, and Linux  */"
39 .BR "#include <unistd.h>"       "    /* BSD 系のシステムと Linux の場合  */"
40 .br
41 .\"O .BR "#include <stdlib.h>"       "    /* on System V-like systems */"
42 .BR "#include <stdlib.h>"       "    /* System V 系のシステムの場合 */"
43 .sp
44 .B "int ttyslot(void);"
45 .sp
46 .in -4n
47 .\"O Feature Test Macro Requirements for glibc (see
48 .\"O .BR feature_test_macros (7)):
49 glibc 向けの機能検査マクロの要件
50 .RB ( feature_test_macros (7)
51 参照):
52 .in
53 .sp
54 .ad l
55 .BR ttyslot ():
56 .RS 4
57 _BSD_SOURCE ||
58 .br
59 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_\ <\ 500\ &&\ _XOPEN_SOURCE_EXTENDED
60 .RE
61 .ad b
62 .\"O .SH DESCRIPTION
63 .SH 説明
64 .\"O The legacy function
65 .\"O .BR ttyslot ()
66 .\"O returns the index of the current user's entry in some file.
67 レガシーな関数
68 .BR ttyslot ()
69 は、あるファイルに書かれているカレントユーザのエントリのインデックスを返す。
70 .LP
71 .\"O Now "What file?" you ask.
72 .\"O Well, let's first look at some history.
73 「どのファイルなのか?」という質問があるだろう。
74 では、まず最初にその歴史を見てみよう。
75 .\"O .SS "Ancient History"
76 .SS 大昔の歴史
77 .\"O There used to be a file
78 .\"O .I /etc/ttys
79 .\"O in UNIX V6, that was read by the
80 .\"O .BR init (8)
81 .\"O program to find out what to do with each terminal line.
82 UNIX V6 では
83 .I /etc/ttys
84 ファイルが使われていた。
85 .BR init (8)
86 プログラムは、このファイルを読み込み、
87 各端末行で何をすべきかを探す。
88 .\"O Each line consisted of three characters.
89 各行は 3 文字から構成されている。
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
97 .\"O .BR getty (8)
98 .\"O indicating the sequence of line speeds to try (\(aq\-\(aq was: start trying
99 .\"O 110 baud).
100 .\"O Thus a typical line was "18\-".
101 3 文字目は
102 .BR getty (8)
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 に再度シグナルを送ることで解決する。
111 .LP
112 .\"O In UNIX V7 the format was changed: here the second character
113 .\"O was the argument to
114 .\"O .BR getty (8)
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 ではフォーマットが変更された:
120 2 文字目が
121 .BR getty (8)
122 の引き数となり、(接続を) 試みる回線速度の順序を表すようになり
123 (\(aq0\(aq は 300-1200-150-110 を繰り返すことを表し、
124 \(aq4\(aq はオンラインコンソール DECwriter を表す)、
125 行の残り (の文字) は端末名となった。
126 よって、一般的な行は "14console" となる。
127 .LP
128 .\"O Later systems have more elaborate syntax.
129 後者のシステムの書式は、より精巧である。
130 .\"O System V-like systems have
131 .\"O .I /etc/inittab
132 .\"O instead.
133 System V 系のシステムでは、代わりに
134 .I /etc/inittab
135 がある。
136 .\"O .SS "Ancient History (2)"
137 .SS "大昔の歴史 (2)"
138 .\"O On the other hand, there is the file
139 .\"O .I /etc/utmp
140 .\"O listing the people currently logged in.
141 .\"O It is maintained by
142 .\"O .BR login (1).
143 一方、現在ログインしている人をリストするファイル
144 .I /etc/utmp
145 がある。
146 これは
147 .BR login (1)
148 によって管理されている。
149 .\"O It has a fixed size, and the appropriate index in the file was
150 .\"O determined by
151 .\"O .BR login (1)
152 .\"O using the
153 .\"O .BR ttyslot ()
154 .\"O call to find the number of the line in
155 .\"O .I /etc/ttys
156 .\"O (counting from 1).
157 このファイルは固定されたサイズであり、ファイル内の適切なインデックスは、
158 .BR login (1)
159 によって決定される。
160 この際に
161 .BR ttyslot ()
162 が呼ばれて、
163 .I /etc/ttys
164 における行番号を見つける (行番号は 1 から数える)。
165 .\"O .SS "The semantics of ttyslot"
166 .SS "ttyslot の意味"
167 .\"O Thus, the function
168 .\"O .BR ttyslot ()
169 .\"O returns the index of the controlling terminal of the calling process
170 .\"O in the file
171 .\"O .IR /etc/ttys ,
172 .\"O and that is (usually) the same as the index of the entry for the
173 .\"O current user in the file
174 .\"O .IR /etc/utmp .
175 よって、関数
176 .BR ttyslot ()
177 は、ファイル
178 .I /etc/ttys
179 における呼び出し元のプロセスの制御端末のインデックスを返す。
180 これは
181 .I /etc/utmp
182 におけるカレントユーザのエントリのインデックスと (通常は) 等しい。
183 .\"O BSD still has the
184 .\"O .I /etc/ttys
185 .\"O file, but System V-like systems do not, and hence cannot refer to it.
186 BSD には未だに
187 .I /etc/ttys
188 ファイルがあるが、System V 系のシステムにはないので、
189 このファイルを参照することはできない。
190 .\"O Thus, on such systems the documentation says that
191 .\"O .BR ttyslot ()
192 .\"O returns the current user's index in the user accounting data base.
193 よって、そのようなシステムでは
194 .RB 「 ttyslot ()
195 はカレントユーザのユーザアカウントデータベースにおけるインデックスを返す」
196 とドキュメントに書かれている。
197 .\"O .SH "RETURN VALUE"
198 .SH 返り値
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.
205 エラーの場合
206 (例えば、ファイルディスクリプタ 0, 1, 2 の何れも
207 データベースにある端末に関連づけられていない場合)、
208 UNIX V6, V7, BSD 系のシステムは 0 を返すが、
209 System V 系のシステムは -1 を返す。
210 .\"O .SH "CONFORMING TO"
211 .SH 準拠
212 .\"O SUSv1; marked as LEGACY in SUSv2; removed in POSIX.1-2001.
213 .\"O SUSv2 requires \-1 on error.
214 SUSv1。SUSv2 では「過去の名残 (LEGACY)」と位置付けられている。
215 POSIX.1-2001 で削除された。
216 SUSv2 ではエラー時に \-1 を返すことが要求されている。
217 .\"O .SH NOTES
218 .SH 注意
219 .\"O The utmp file is found various places on various systems, such as
220 .\"O .IR /etc/utmp ,
221 .\"O .IR /var/adm/utmp ,
222 .\"O .IR /var/run/utmp .
223 utmp ファイルは様々なシステムで
224 .IR /etc/utmp ,
225 .IR /var/adm/utmp ,
226 .I /var/run/utmp
227 のようにいろいろな場所にある。
228 .LP
229 .\"O The glibc2 implementation of this function reads the file
230 .\"O .BR _PATH_TTYS ,
231 .\"O defined in
232 .\"O .I <ttyent.h>
233 .\"O as "/etc/ttys".
234 .\"O It returns 0 on error.
235 この関数の glibc2 における実装では、ファイル
236 .B _PATH_TTYS
237 を読み込む。
238 これは
239 .I <ttyent.h>
240 において "/etc/ttys" と定義されている。
241 エラーの場合、0 を返す。
242 .\"O Since Linux systems do not usually have "/etc/ttys", it will
243 .\"O always return 0.
244 Linux システムには通常 "/etc/ttys" がないので、常に 0 を返す。
245 .LP
246 .\"O Minix also has
247 .\"O .IR fttyslot ( fd ).
248 Minix には
249 .IR fttyslot ( fd )
250 もある。
251 .\"O .\" .SH HISTORY
252 .\" .SH 履歴
253 .\"O .\" .BR ttyslot ()
254 .\"O .\" appeared in UNIX V7.
255 .\" .BR ttyslot ()
256 .\" は UNIX V7 で登場した。
257 .\"O .SH "SEE ALSO"
258 .SH 関連項目
259 .BR getttyent (3),
260 .BR ttyname (3),
261 .BR utmp (5)