OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / 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 2007-11-26 "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 _BSD_SOURCE || (_XOPEN_SOURCE_EXTENDED && !\ _XOPEN_SOURCE\ >=\ 500)
57 .ad b
58 .\"O .SH DESCRIPTION
59 .SH ÀâÌÀ
60 .\"O The legacy function
61 .\"O .BR ttyslot ()
62 .\"O returns the index of the current user's entry in some file.
63 ¥ì¥¬¥·¡¼¤Ê´Ø¿ô
64 .BR ttyslot ()
65 ¤Ï¡¢¤¢¤ë¥Õ¥¡¥¤¥ë¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¥«¥ì¥ó¥È¥æ¡¼¥¶¤Î¥¨¥ó¥È¥ê¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤òÊÖ¤¹¡£
66 .LP
67 .\"O Now "What file?" you ask.
68 .\"O Well, let's first look at some history.
69 ¡Ö¤É¤Î¥Õ¥¡¥¤¥ë¤Ê¤Î¤«¡©¡×¤È¤¤¤¦¼ÁÌ䤬¤¢¤ë¤À¤í¤¦¡£
70 ¤Ç¤Ï¡¢¤Þ¤ººÇ½é¤Ë¤½¤ÎÎò»Ë¤ò¸«¤Æ¤ß¤è¤¦¡£
71 .\"O .SS "Ancient History"
72 .SS ÂçÀΤÎÎò»Ë
73 .\"O There used to be a file
74 .\"O .I /etc/ttys
75 .\"O in Unix V6, that was read by the
76 .\"O .BR init (8)
77 .\"O program to find out what to do with each terminal line.
78 Unix V6 ¤Ç¤Ï
79 .I /etc/ttys
80 ¥Õ¥¡¥¤¥ë¤¬»È¤ï¤ì¤Æ¤¤¤¿¡£
81 .BR init (8)
82 ¥×¥í¥°¥é¥à¤Ï¡¢¤³¤Î¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ß¡¢
83 ³ÆüËö¹Ô¤Ç²¿¤ò¤¹¤Ù¤­¤«¤òõ¤¹¡£
84 .\"O Each line consisted of three characters.
85 ³Æ¹Ô¤Ï 3 Ê¸»ú¤«¤é¹½À®¤µ¤ì¤Æ¤¤¤ë¡£
86 .\"O The first character was either \(aq0\(aq or \(aq1\(aq,
87 .\"O where \(aq0\(aq meant "ignore".
88 1 Ê¸»úÌܤϠ\(aq0\(aq ¤Þ¤¿¤Ï \(aq1\(aq ¤Ç¤¢¤ê¡¢
89 \(aq0\(aq ¤Ï¡Ö̵»ë¤¹¤ë¡×¤³¤È¤òɽ¤¹¡£
90 .\"O The second character denoted the terminal: \(aq8\(aq stood for "/dev/tty8".
91 2 Ê¸»úÌܤÏüËö¤ò¼¨¤¹: \(aq8\(aq ¤Ï "/dev/tty8" ¤òɽ¤¹¡£
92 .\"O The third character was an argument to
93 .\"O .BR getty (8)
94 .\"O indicating the sequence of line speeds to try (\(aq\-\(aq was: start trying
95 .\"O 110 baud).
96 .\"O Thus a typical line was "18\-".
97 3 Ê¸»úÌܤÏ
98 .BR getty (8)
99 ¤Ø¤Î°ú¤­¿ô¤Ç¤¢¤ê¡¢(Àܳ¤ò) »î¤ß¤ë²óÀþ®Å٤νç½ø¤òɽ¤¹
100 (\(aq\-\(aq ¤Ï 110 ¥Ü¡¼¤ÇÀܳ¤Î»î¹Ô¤ò³«»Ï¤¹¤ë¤³¤È¤òɽ¤¹)¡£
101 ¤è¤Ã¤Æ°ìÈÌŪ¤Ê¹Ô¤Ï "18\-" ¤È¤Ê¤ë¡£
102 .\"O A hang on some line was solved by changing the \(aq1\(aq to a \(aq0\(aq,
103 .\"O signaling init, changing back again, and signaling init again.
104 ¤¢¤ë¹Ô¤Ç¥Ï¥ó¥°¤·¤¿¾ì¹ç¤Ï¡¢\(aq1\(aq ¤ò \(aq0\(aq ¤ËÊѹ¹¤·¡¢
105 init ¤Ë¥·¥°¥Ê¥ë¤òÁ÷¤ê¡¢\(aq0\(aq ¤ò \(aq1\(aq ºÆÅÙ¤ËÊѹ¹¤·¡¢
106 init ¤ËºÆÅÙ¥·¥°¥Ê¥ë¤òÁ÷¤ë¤³¤È¤Ç²ò·è¤¹¤ë¡£
107 .LP
108 .\"O In Unix V7 the format was changed: here the second character
109 .\"O was the argument to
110 .\"O .BR getty (8)
111 .\"O indicating the sequence of line speeds to try (\(aq0\(aq was: cycle through
112 .\"O 300-1200-150-110 baud; \(aq4\(aq was for the on-line console DECwriter)
113 .\"O while the rest of the line contained the name of the tty.
114 .\"O Thus a typical line was "14console".
115 Unix V7 ¤Ç¤Ï¥Õ¥©¡¼¥Þ¥Ã¥È¤¬Êѹ¹¤µ¤ì¤¿:
116 2 Ê¸»úÌܤ¬
117 .BR getty (8)
118 ¤Î°ú¤­¿ô¤È¤Ê¤ê¡¢(Àܳ¤ò) »î¤ß¤ë²óÀþ®Å٤νç½ø¤òɽ¤¹¤è¤¦¤Ë¤Ê¤ê
119 (\(aq0\(aq ¤Ï 300-1200-150-110 ¤ò·«¤êÊÖ¤¹¤³¤È¤òɽ¤·¡¢
120 \(aq4\(aq ¤Ï¥ª¥ó¥é¥¤¥ó¥³¥ó¥½¡¼¥ë DECwriter ¤òɽ¤¹)¡¢
121 ¹Ô¤Î»Ä¤ê (¤Îʸ»ú) ¤ÏüËö̾¤È¤Ê¤Ã¤¿¡£
122 ¤è¤Ã¤Æ¡¢°ìÈÌŪ¤Ê¹Ô¤Ï "14console" ¤È¤Ê¤ë¡£
123 .LP
124 .\"O Later systems have more elaborate syntax.
125 ¸å¼Ô¤Î¥·¥¹¥Æ¥à¤Î½ñ¼°¤Ï¡¢¤è¤êÀº¹ª¤Ç¤¢¤ë¡£
126 .\"O System V-like systems have
127 .\"O .I /etc/inittab
128 .\"O instead.
129 System V ·Ï¤Î¥·¥¹¥Æ¥à¤Ç¤Ï¡¢Âå¤ï¤ê¤Ë
130 .I /etc/inittab
131 ¤¬¤¢¤ë¡£
132 .\"O .SS "Ancient History (2)"
133 .SS "ÂçÀΤÎÎò»Ë (2)"
134 .\"O On the other hand, there is the file
135 .\"O .I /etc/utmp
136 .\"O listing the people currently logged in.
137 .\"O It is maintained by
138 .\"O .BR login (1).
139 °ìÊý¡¢¸½ºß¥í¥°¥¤¥ó¤·¤Æ¤¤¤ë¿Í¤ò¥ê¥¹¥È¤¹¤ë¥Õ¥¡¥¤¥ë
140 .I /etc/utmp
141 ¤¬¤¢¤ë¡£
142 ¤³¤ì¤Ï
143 .BR login (1)
144 ¤Ë¤è¤Ã¤Æ´ÉÍý¤µ¤ì¤Æ¤¤¤ë¡£
145 .\"O It has a fixed size, and the appropriate index in the file was
146 .\"O determined by
147 .\"O .BR login (1)
148 .\"O using the
149 .\"O .BR ttyslot ()
150 .\"O call to find the number of the line in
151 .\"O .I /etc/ttys
152 .\"O (counting from 1).
153 ¤³¤Î¥Õ¥¡¥¤¥ë¤Ï¸ÇÄꤵ¤ì¤¿¥µ¥¤¥º¤Ç¤¢¤ê¡¢¥Õ¥¡¥¤¥ëÆâ¤ÎŬÀڤʥ¤¥ó¥Ç¥Ã¥¯¥¹¤Ï¡¢
154 .BR login (1)
155 ¤Ë¤è¤Ã¤Æ·èÄꤵ¤ì¤ë¡£
156 ¤³¤ÎºÝ¤Ë
157 .BR ttyslot ()
158 ¤¬¸Æ¤Ð¤ì¤Æ¡¢
159 .I /etc/ttys
160 ¤Ë¤ª¤±¤ë¹ÔÈÖ¹æ¤ò¸«¤Ä¤±¤ë (¹ÔÈÖ¹æ¤Ï 1 ¤«¤é¿ô¤¨¤ë)¡£
161 .\"O .SS "The semantics of ttyslot"
162 .SS "ttyslot ¤Î°ÕÌ£"
163 .\"O Thus, the function
164 .\"O .BR ttyslot ()
165 .\"O returns the index of the controlling terminal of the calling process
166 .\"O in the file
167 .\"O .IR /etc/ttys ,
168 .\"O and that is (usually) the same as the index of the entry for the
169 .\"O current user in the file
170 .\"O .IR /etc/utmp .
171 ¤è¤Ã¤Æ¡¢´Ø¿ô
172 .BR ttyslot ()
173 ¤Ï¡¢¥Õ¥¡¥¤¥ë
174 .I /etc/ttys
175 ¤Ë¤ª¤±¤ë¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ÎÀ©¸æüËö¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤òÊÖ¤¹¡£
176 ¤³¤ì¤Ï
177 .I /etc/utmp
178 ¤Ë¤ª¤±¤ë¥«¥ì¥ó¥È¥æ¡¼¥¶¤Î¥¨¥ó¥È¥ê¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤È (Ä̾ï¤Ï) Åù¤·¤¤¡£
179 .\"O BSD still has the
180 .\"O .I /etc/ttys
181 .\"O file, but System V-like systems do not, and hence cannot refer to it.
182 BSD ¤Ë¤Ï̤¤À¤Ë
183 .I /etc/ttys
184 ¥Õ¥¡¥¤¥ë¤¬¤¢¤ë¤¬¡¢System V ·Ï¤Î¥·¥¹¥Æ¥à¤Ë¤Ï¤Ê¤¤¤Î¤Ç¡¢
185 ¤³¤Î¥Õ¥¡¥¤¥ë¤ò»²¾È¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
186 .\"O Thus, on such systems the documentation says that
187 .\"O .BR ttyslot ()
188 .\"O returns the current user's index in the user accounting data base.
189 ¤è¤Ã¤Æ¡¢¤½¤Î¤è¤¦¤Ê¥·¥¹¥Æ¥à¤Ç¤Ï
190 .RB ¡Ö ttyslot ()
191 ¤Ï¥«¥ì¥ó¥È¥æ¡¼¥¶¤Î¥æ¡¼¥¶¥¢¥«¥¦¥ó¥È¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¤ª¤±¤ë¥¤¥ó¥Ç¥Ã¥¯¥¹¤òÊÖ¤¹¡×
192 ¤È¥É¥­¥å¥á¥ó¥È¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¡£
193 .\"O .SH "RETURN VALUE"
194 .SH ÊÖ¤êÃÍ
195 .\"O If successful, this function returns the slot number.
196 À®¸ù¤·¤¿¾ì¹ç¡¢¤³¤Î´Ø¿ô¤Ï¥¹¥í¥Ã¥ÈÈÖ¹æ¤òÊÖ¤¹¡£
197 .\"O On error (e.g., if none of the file descriptors 0, 1 or 2 is
198 .\"O associated with a terminal that occurs in this data base)
199 .\"O it returns 0 on Unix V6 and V7 and BSD-like systems,
200 .\"O but \-1 on System V-like systems.
201 ¥¨¥é¡¼¤Î¾ì¹ç
202 (Î㤨¤Ð¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿ 0, 1, 2 ¤Î²¿¤ì¤â
203 ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Ë¤¢¤ëüËö¤Ë´ØÏ¢¤Å¤±¤é¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç)¡¢
204 Unix V6, V7, BSD ·Ï¤Î¥·¥¹¥Æ¥à¤Ï 0 ¤òÊÖ¤¹¤¬¡¢
205 System V ·Ï¤Î¥·¥¹¥Æ¥à¤Ï -1 ¤òÊÖ¤¹¡£
206 .\"O .SH "CONFORMING TO"
207 .SH ½àµò
208 .\"O SUSv1; marked as LEGACY in SUSv2; removed in POSIX.1-2001.
209 .\"O SUSv2 requires \-1 on error.
210 SUSv1¡£SUSv2 ¤Ç¤Ï¡Ö²áµî¤Î̾»Ä (LEGACY)¡×¤È°ÌÃÖÉÕ¤±¤é¤ì¤Æ¤¤¤ë¡£
211 POSIX.1-2001 ¤Çºï½ü¤µ¤ì¤¿¡£
212 SUSv2 ¤Ç¤Ï¥¨¥é¡¼»þ¤Ë \-1 ¤òÊÖ¤¹¤³¤È¤¬Í׵ᤵ¤ì¤Æ¤¤¤ë¡£
213 .\"O .SH NOTES
214 .SH Ãí°Õ
215 .\"O The utmp file is found various places on various systems, such as
216 .\"O .IR /etc/utmp ,
217 .\"O .IR /var/adm/utmp ,
218 .\"O .IR /var/run/utmp .
219 utmp ¥Õ¥¡¥¤¥ë¤ÏÍÍ¡¹¤Ê¥·¥¹¥Æ¥à¤Ç
220 .IR /etc/utmp ,
221 .IR /var/adm/utmp ,
222 .I /var/run/utmp
223 ¤Î¤è¤¦¤Ë¤¤¤í¤¤¤í¤Ê¾ì½ê¤Ë¤¢¤ë¡£
224 .LP
225 .\"O The glibc2 implementation of this function reads the file
226 .\"O .BR _PATH_TTYS ,
227 .\"O defined in
228 .\"O .I <ttyent.h>
229 .\"O as "/etc/ttys".
230 .\"O It returns 0 on error.
231 ¤³¤Î´Ø¿ô¤Î glibc2 ¤Ë¤ª¤±¤ë¼ÂÁõ¤Ç¤Ï¡¢¥Õ¥¡¥¤¥ë
232 .B _PATH_TTYS
233 ¤òÆɤ߹þ¤à¡£
234 ¤³¤ì¤Ï
235 .I <ttyent.h>
236 ¤Ë¤ª¤¤¤Æ "/etc/ttys" ¤ÈÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
237 ¥¨¥é¡¼¤Î¾ì¹ç¡¢0 ¤òÊÖ¤¹¡£
238 .\"O Since Linux systems do not usually have "/etc/ttys", it will
239 .\"O always return 0.
240 Linux ¥·¥¹¥Æ¥à¤Ë¤ÏÄ̾ï "/etc/ttys" ¤¬¤Ê¤¤¤Î¤Ç¡¢¾ï¤Ë 0 ¤òÊÖ¤¹¡£
241 .LP
242 .\"O Minix also has
243 .\"O .IR fttyslot ( fd ).
244 Minix ¤Ë¤Ï
245 .IR fttyslot ( fd )
246 ¤â¤¢¤ë¡£
247 .\"O .\" .SH HISTORY
248 .\" .SH ÍúÎò
249 .\"O .\" .BR ttyslot ()
250 .\"O .\" appeared in Unix V7.
251 .\" .BR ttyslot ()
252 .\" ¤Ï Unix V7 ¤ËÅо줷¤¿¡£
253 .\"O .SH "SEE ALSO"
254 .SH ´ØÏ¢¹àÌÜ
255 .BR getttyent (3),
256 .BR ttyname (3),
257 .BR utmp (5)