OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / draft / man2 / fcntl.2
1 '\" t
2 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\"
4 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
5 .\"                 and Copyright (C) 1993 Michael Haardt, Ian Jackson;
6 .\"                 and Copyright (C) 1998 Jamie Lokier;
7 .\"                 and Copyright (C) 2002 Michael Kerrisk.
8 .\"
9 .\" Permission is granted to make and distribute verbatim copies of this
10 .\" manual provided the copyright notice and this permission notice are
11 .\" preserved on all copies.
12 .\"
13 .\" Permission is granted to copy and distribute modified versions of this
14 .\" manual under the conditions for verbatim copying, provided that the
15 .\" entire resulting derived work is distributed under the terms of a
16 .\" permission notice identical to this one.
17 .\"
18 .\" Since the Linux kernel and libraries are constantly changing, this
19 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
20 .\" responsibility for errors or omissions, or for damages resulting from
21 .\" the use of the information contained herein.  The author(s) may not
22 .\" have taken the same level of care in the production of this manual,
23 .\" which is licensed free of charge, as they might when working
24 .\" professionally.
25 .\"
26 .\" Formatted or processed versions of this manual, if unaccompanied by
27 .\" the source, must acknowledge the copyright and authors of this work.
28 .\"
29 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
30 .\" Modified 1995-09-26 by Andries Brouwer <aeb@cwi.nl>
31 .\" and again on 960413 and 980804 and 981223.
32 .\" Modified 1998-12-11 by Jamie Lokier <jamie@imbolc.ucc.ie>
33 .\" Applied correction by Christian Ehrhardt - aeb, 990712
34 .\" Modified 2002-04-23 by Michael Kerrisk <mtk.manpages@gmail.com>
35 .\"     Added note on F_SETFL and O_DIRECT
36 .\"     Complete rewrite + expansion of material on file locking
37 .\"     Incorporated description of F_NOTIFY, drawing on
38 .\"             Stephen Rothwell's notes in Documentation/dnotify.txt.
39 .\"     Added description of F_SETLEASE and F_GETLEASE
40 .\" Corrected and polished, aeb, 020527.
41 .\" Modified 2004-03-03 by Michael Kerrisk <mtk.manpages@gmail.com>
42 .\"     Modified description of file leases: fixed some errors of detail
43 .\"     Replaced the term "lease contestant" by "lease breaker"
44 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
45 .\"     Added notes on capability requirements
46 .\" Modified 2004-12-08, added O_NOATIME after note from Martin Pool
47 .\" 2004-12-10, mtk, noted F_GETOWN bug after suggestion from aeb.
48 .\" 2005-04-08 Jamie Lokier <jamie@shareable.org>, mtk
49 .\"     Described behavior of F_SETOWN/F_SETSIG in
50 .\"     multithreaded processes, and generally cleaned
51 .\"     up the discussion of F_SETOWN.
52 .\" 2005-05-20, Johannes Nicolai <johannes.nicolai@hpi.uni-potsdam.de>,
53 .\"     mtk: Noted F_SETOWN bug for socket file descriptor in Linux 2.4
54 .\"     and earlier.  Added text on permissions required to send signal.
55 .\" 2009-09-30, Michael Kerrisk
56 .\"     Note obsolete F_SETOWN behavior with threads.
57 .\"     Document F_SETOWN_EX and F_GETOWN_EX
58 .\"
59 .\" Japanese Version Copyright (c) 1996 Takeshi Ueno
60 .\" and Copyright (c) 2005, 2006, 2008 Akihiro MOTOKI
61 .\"
62 .\" Translated 1996-07-03, Takeshi Ueno <tueno@vio.co.jp>
63 .\" Modified 1998-09-10, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
64 .\" Modified 1999-08-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
65 .\" Updated & Modified 2001-04-03, Yuichi SATO <ysato@h4.dion.ne.jp>
66 .\" Updated & Modified 2005-03-15, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
67 .\" Updated & Modified 2005-04-22, Akihiro MOTOKI
68 .\" Updated & Modified 2005-10-14, Akihiro MOTOKI
69 .\" Updated & Modified 2005-11-19, Akihiro MOTOKI, LDP v2.14
70 .\" Updated 2006-04-16, Akihiro MOTOKI, LDP v2.29
71 .\" Updated 2008-02-11, Akihiro MOTOKI, LDP v2.77
72 .\" Updated 2008-09-19, Akihiro MOTOKI, LDP v3.09
73 .\" Updated 2010-04-23, Akihiro MOTOKI, LDP v3.24
74 .\"
75 .\"WORD:        asynchronous I/O        ÈóƱ´ü I/O
76 .\"WORD:        descriptor              ¥Ç¥£¥¹¥¯¥ê¥×¥¿
77 .\"WORD:        open file description   ¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ëµ­½Ò
78 .\"WORD:        feature test macro      µ¡Ç½¸¡ºº¥Þ¥¯¥í
79 .\"WORD:        I/O availability signal I/O ¤¬ÍøÍѲÄǽ¤Ë¤Ê¤Ã¤¿¤³¤È¤ò¼¨¤¹¥·¥°¥Ê¥ë
80 .\"
81 .TH FCNTL 2 2009-10-17 "Linux" "Linux Programmer's Manual"
82 .\"O .SH NAME
83 .SH Ì¾Á°
84 .\"O fcntl \- manipulate file descriptor
85 fcntl \- ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÎÁàºî¤ò¹Ô¤¦
86 .\"O .SH SYNOPSIS
87 .SH ½ñ¼°
88 .nf
89 .B #include <unistd.h>
90 .B #include <fcntl.h>
91 .sp
92 .BI "int fcntl(int " fd ", int " cmd ", ... /* " arg " */ );"
93 .fi
94 .\"O .SH DESCRIPTION
95 .SH ÀâÌÀ
96 .\"O .BR fcntl ()
97 .\"O performs one of the operations described below on the open file descriptor
98 .\"O .IR fd .
99 .\"O The operation is determined by
100 .\"O .IR cmd .
101 .BR fcntl ()
102 ¤Ï¡¢¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
103 .I fd
104 ¤Ë´Ø¤·¤Æ²¼µ­¤ÎÁàºî¤ò¹Ô¤¦¡£Áàºî¤Ï
105 .I cmd
106 ¤Ë¤è¤Ã¤Æ·è¤Þ¤ë:
107
108 .\"O .BR fcntl ()
109 .\"O can take an optional third argument.
110 .\"O Whether or not this argument is required is determined by
111 .\"O .IR cmd .
112 .\"O The required argument type is indicated in parentheses after each
113 .\"O .I cmd
114 .\"O name (in most cases, the required type is
115 .\"O .IR long ,
116 .\"O and we identify the argument using the name
117 .\"O .IR arg ),
118 .\"O or
119 .\"O .I void
120 .\"O is specified if the argument is not required.
121 .BR fcntl ()
122 ¤Ï¥ª¥×¥·¥ç¥ó¤È¤·¤ÆÂè»°°ú¤­¿ô¤ò¤È¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
123 Âè»°°ú¤­¿ô¤¬É¬Íפ«¤É¤¦¤«¤Ï
124 .I cmd
125 ¤Ë¤è¤ê·è¤Þ¤ë¡£
126 ɬÍפʰú¤­¿ô¤Î·¿¤Ï
127 .I cmd
128 ̾¤Î¸å¤í¤Î³ç¸ÌÆâ¤Ç»ØÄꤵ¤ì¤Æ¤¤¤ë
129 (¤Û¤È¤ó¤É¤Î¾ì¹ç¡¢É¬Íפʷ¿¤Ï
130 .I long
131 ¤Ç¤¢¤ê¡¢¤³¤Î°ú¤­¿ô¤òɽ¤¹¤Î¤Ë
132 .I arg
133 ¤È¤¤¤¦Ì¾Á°¤ò»È¤Ã¤Æ¤¤¤ë)¡£
134 °ú¤­¿ô¤¬É¬Íפʤ¤¾ì¹ç¤Ë¤Ï
135 .I void
136 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¡£
137 .\"O .SS "Duplicating a file descriptor"
138 .SS "¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÎÊ£À½"
139 .TP
140 .BR F_DUPFD " (\fIlong\fP)"
141 .\"O Find the lowest numbered available file descriptor
142 .\"O greater than or equal to
143 .\"O .I arg
144 .\"O and make it be a copy of
145 .\"O .IR fd .
146 .\"O This is different from
147 .\"O .BR dup2 (2),
148 .\"O which uses exactly the descriptor specified.
149 ÍøÍѲÄǽ¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¤¦¤Á¡¢
150 .I arg
151 °Ê¾å¤ÇºÇ¾®¤Î¤â¤Î¤òõ¤·¡¢
152 .I fd
153 ¤Î¥³¥Ô¡¼¤È¤¹¤ë¡£¤³¤ì¤ÏÊ̤ηÁ¤Î
154 .BR dup2 (2)
155 ¤Ç¤¢¤ë¡£
156 .BR dup2 (2)
157 ¤Ç¤Ï»ØÄꤵ¤ì¤¿¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬»È¤ï¤ì¤ëÅÀ¤¬°ã¤¦¡£
158 .IP
159 .\"O On success, the new descriptor is returned.
160 À®¸ù¤¹¤ë¤È¡¢¿·¤·¤¤¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬ÊÖ¤µ¤ì¤ë¡£
161 .IP
162 .\"O See
163 .\"O .BR dup (2)
164 .\"O for further details.
165 ¾ÜºÙ¤Ï
166 .BR dup (2)
167 ¤ò»²¾È¤Î¤³¤È¡£
168 .TP
169 .\"O .BR F_DUPFD_CLOEXEC " (\fIlong\fP; since Linux 2.6.24)"
170 .BR F_DUPFD_CLOEXEC " (\fIlong\fP; Linux 2.6.24 °Ê¹ß)"
171 .\"O As for
172 .\"O .BR F_DUPFD ,
173 .\"O but additionally set the
174 .\"O close-on-exec flag for the duplicate descriptor.
175 .B F_DUPFD
176 ¤ÈƱÍͤÀ¤¬¡¢¤½¤ì¤Ë²Ã¤¨¤ÆÊ£À½¤µ¤ì¤¿¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ·¤Æ
177 close-on-exec ¥Õ¥é¥°¤ò¥»¥Ã¥È¤¹¤ë¡£
178 .\"O Specifying this flag permits a program to avoid an additional
179 .\"O .BR fcntl ()
180 .\"O .B F_SETFD
181 .\"O operation to set the
182 .\"O .B FD_CLOEXEC
183 .\"O flag.
184 ¤³¤Î¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤³¤È¤Ç¡¢¥×¥í¥°¥é¥à¤Ï
185 .B FD_CLOEXEC
186 ¥Õ¥é¥°¤ò¥»¥Ã¥È¤¹¤ë¤¿¤á¤Ë
187 .BR fcntl ()
188 ¤Î
189 .B F_SETFD
190 Áàºî¤òÄɲäǹԤ¦É¬Íפ¬¤Ê¤¯¤Ê¤ë¡£
191 .\"O For an explanation of why this flag is useful,
192 .\"O see the description of
193 .\"O .B O_CLOEXEC
194 .\"O in
195 .\"O .BR open (2).
196 ¤³¤Î¥Õ¥é¥°¤¬¤Ê¤¼Í­ÍѤ«¤Ë¤Ä¤¤¤Æ¤Ï¡¢
197 .BR open (2)
198 ¤Î
199 .B O_CLOEXEC
200 ¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£
201 .\"O .SS "File descriptor flags"
202 .SS "¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¦¥Õ¥é¥°"
203 .\"O The following commands manipulate the flags associated with
204 .\"O a file descriptor.
205 .\"O Currently, only one such flag is defined:
206 .\"O .BR FD_CLOEXEC ,
207 .\"O the close-on-exec flag.
208 .\"O If the
209 .\"O .B FD_CLOEXEC
210 .\"O bit is 0, the file descriptor will remain open across an
211 .\"O .BR execve (2),
212 .\"O otherwise it will be closed.
213 °Ê²¼¤Î¥³¥Þ¥ó¥É¤ò»È¤Ã¤Æ¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë´ØÏ¢¤¹¤ë¥Õ¥é¥°
214 ¤òÁàºî¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
215 ¸½ºß¤Î¤È¤³¤í¡¢ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥Õ¥é¥°¤Ï°ì¤Ä¤À¤±¤Ç¤¢¤ë:
216 .B FD_CLOEXEC
217 (close-on-exec ¥Õ¥é¥°)¡£
218 .B FD_CLOEXEC
219 ¥Ó¥Ã¥È¤¬ 0 ¤Ê¤é¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï
220 .BR execve (2)
221 ¤ò¹Ô¤Ã¤Æ¤â¥ª¡¼¥×¥ó¤µ¤ì¤¿¤Þ¤Þ¤À¤¬¡¢¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ï¥¯¥í¡¼¥º¤µ¤ì¤ë¡£
222 .TP
223 .BR F_GETFD " (\fIvoid\fP)"
224 .\"O Read the file descriptor flags;
225 .\"O .I arg
226 .\"O is ignored.
227 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¦¥Õ¥é¥°¤òÆɤ߽Ф¹¡£
228 .I arg
229 ¤Ï̵»ë¤µ¤ì¤ë¡£
230 .TP
231 .BR F_SETFD " (\fIlong\fP)"
232 .\"O Set the file descriptor flags to the value specified by
233 .\"O .IR arg .
234 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¦¥Õ¥é¥°¤Ë
235 .I arg
236 ¤Ç»ØÄꤷ¤¿ÃͤòÀßÄꤹ¤ë¡£
237 .\"O .SS "File status flags"
238 .SS "¥Õ¥¡¥¤¥ë¾õÂ֥ե饰"
239 .\"O Each open file description has certain associated status flags,
240 .\"O initialized by
241 .\"O .BR open (2)
242 .\"O .\" or
243 .\"O .\" .BR creat (2),
244 .\"O and possibly modified by
245 .\"O .BR fcntl ().
246 .\"O Duplicated file descriptors
247 .\"O (made with
248 .\"O .BR dup (2),
249 .\"O .BR fcntl (F_DUPFD),
250 .\"O .BR fork (2),
251 .\"O etc.) refer to the same open file description, and thus
252 .\"O share the same file status flags.
253 ¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ëµ­½Ò (open file description) ¤Ë¤Ï¡¢
254 ¥Õ¥¡¥¤¥ëµ­½ÒËè¤ËÀßÄꤵ¤ì¤ë¾õÂ֥ե饰¤¬¤¤¤¯¤Ä¤«¤¢¤ë¡£¤³¤ì¤é¤Î¥Õ¥é¥°¤Ï
255 .BR open (2)
256 .\" ¤ä
257 .\" .BR creat (2)
258 ¤Ë¤è¤Ã¤Æ½é´ü²½¤µ¤ì¡¢
259 .BR fcntl (2)
260 ¤Ë¤è¤êÊѹ¹¤¹¤ë¤³¤È¤â¤Ç¤­¤ë¡£¤³¤ì¤é¤Ï¡¢
261 .RB ( dup (2),
262 .BR fcntl (F_DUPFD),
263 .BR fork (2)
264 ¤Ê¤É¤Ç) Ê£À½¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿Æ±»Î¤Ï
265 Ʊ¤¸¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ëµ­½Ò¤ò»²¾È¤¹¤ë¡£
266 ¤½¤Î¤¿¤á¡¢
267 Ʊ¤¸¥Õ¥¡¥¤¥ë¾õÂ֥ե饰¤¬¶¦Í­¤µ¤ì¤ë¡£
268
269 .\"O The file status flags and their semantics are described in
270 .\"O .BR open (2).
271 ¥Õ¥¡¥¤¥ë¾õÂ֥ե饰¤È¤½¤Î°ÕÌ£¤Ï
272 .BR open (2)
273 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë¡£
274 .TP
275 .BR F_GETFL " (\fIvoid\fP)"
276 .\"O Read the file status flags;
277 .\"O .I arg
278 .\"O is ignored.
279 ¥Õ¥¡¥¤¥ë¾õÂ֥ե饰¤òÆɤ߽Ф¹¡£
280 .I arg
281 ¤Ï̵»ë¤µ¤ì¤ë¡£
282 .TP
283 .BR F_SETFL " (\fIlong\fP)"
284 .\"O Set the file status flags to the value specified by
285 .\"O .IR arg .
286 .\"O File access mode
287 .\"O .RB ( O_RDONLY ", " O_WRONLY ", " O_RDWR )
288 .\"O and file creation flags
289 .\"O (i.e.,
290 .\"O .BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", " O_TRUNC )
291 .\"O in
292 .\"O .I arg
293 .\"O are ignored.
294 ¥Õ¥¡¥¤¥ë¾õÂ֥ե饰¤Ë
295 .I arg
296 ¤Ç»ØÄꤵ¤ì¤¿ÃͤòÀßÄꤹ¤ë¡£
297 .I arg
298 ¤Î¤¦¤Á¡¢¥Õ¥¡¥¤¥ë¤Î¥¢¥¯¥»¥¹¥â¡¼¥É
299 .RB ( O_RDONLY ", " O_WRONLY ", " O_RDWR )
300 ¤È¥Õ¥¡¥¤¥ëºîÀ®¥Õ¥é¥° (¤¹¤Ê¤ï¤Á
301 .BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", " O_TRUNC )
302 ¤Ë´Ø¤¹¤ë¥Ó¥Ã¥È¤Ï̵»ë¤µ¤ì¤ë¡£
303 .\"O On Linux this command can only change the
304 .\"O .BR O_APPEND ,
305 .\"O .BR O_ASYNC ,
306 .\"O .BR O_DIRECT ,
307 .\"O .BR O_NOATIME ,
308 .\"O and
309 .\"O .B O_NONBLOCK
310 .\"O flags.
311 Linux ¤Ç¤Ï¡¢¤³¤Î¥³¥Þ¥ó¥É¤ÇÊѹ¹¤Ç¤­¤ë¤Î¤Ï
312 .BR O_APPEND ,
313 .BR O_ASYNC ,
314 .BR O_DIRECT ,
315 .BR O_NOATIME ,
316 .B O_NONBLOCK
317 ¥Õ¥é¥°¤À¤±¤Ç¤¢¤ë¡£
318 .\"O .\" FIXME . According to POSIX.1-2001, O_SYNC should also be modifiable
319 .\"O .\" via fcntl(2), but currently Linux does not permit this
320 .\"O .\" See http://bugzilla.kernel.org/show_bug.cgi?id=5994
321 .\" FIXME . POSIX.1-2001 ¤Ë¤è¤ë¤È¡¢ O_SYNC ¤â fcntl(2) ¤ÇÊѹ¹¤Ç¤­¤ë¤Ù¤­¤À¤¬¡¢
322 .\" ¸½ºß¤Î¤È¤³¤í Linux ¤Ç¤Ïµö²Ä¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
323 .\" http://bugzilla.kernel.org/show_bug.cgi?id=5994 »²¾È
324 .\"O .SS "Advisory locking"
325 .SS "¥¢¥É¥Ð¥¤¥¶¥ê¡¦¥í¥Ã¥¯"
326 .\"O .BR F_GETLK ", " F_SETLK " and " F_SETLKW
327 .\"O are used to acquire, release, and test for the existence of record
328 .\"O locks (also known as file-segment or file-region locks).
329 .\"O The third argument,
330 .\"O .IR lock ,
331 .\"O is a pointer to a structure that has at least the following fields
332 .\"O (in unspecified order).
333 .BR F_GETLK ", " F_SETLK ", " F_SETLKW
334 ¤Ï¡¢¥ì¥³¡¼¥É¡¦¥í¥Ã¥¯¤Î³ÍÆÀ¡¿²òÊü¡¿¥Æ¥¹¥È¤Î¤¿¤á¤Ë»ÈÍѤ¹¤ë
335 (¥ì¥³¡¼¥É¡¦¥í¥Ã¥¯¤Ï¥Õ¥¡¥¤¥ë¥»¥°¥á¥ó¥È¡¦¥í¥Ã¥¯¤ä
336 ¥Õ¥¡¥¤¥ëÎΰè¥í¥Ã¥¯¤È¤â¸Æ¤Ð¤ì¤ë)¡£
337 »°ÈÖÌܤΰú¤­¿ô
338 .I lock
339 ¤Ï¡¢°Ê²¼¤Ë¼¨¤¹¥Õ¥£¡¼¥ë¥É¤ò´Þ¤à¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤Ç¤¢¤ë
340 (¥Õ¥£¡¼¥ë¥É¤Î½ç½ø¤Ï´Ø·¸¤Ê¤¯¡¢¹½Â¤ÂΤ˾¤Î¥Õ¥£¡¼¥ë¥É¤¬¤¢¤Ã¤Æ¤â¤è¤¤)¡£
341 .in +4n
342 .nf
343 .sp
344 struct flock {
345     ...
346     short l_type;    /* Type of lock: F_RDLCK,
347                         F_WRLCK, F_UNLCK */
348     short l_whence;  /* How to interpret l_start:
349                         SEEK_SET, SEEK_CUR, SEEK_END */
350     off_t l_start;   /* Starting offset for lock */
351     off_t l_len;     /* Number of bytes to lock */
352     pid_t l_pid;     /* PID of process blocking our lock
353                         (F_GETLK only) */
354     ...
355 };
356 .fi
357 .in
358 .P
359 .\"O The
360 .\"O .IR l_whence ", " l_start ", and " l_len
361 .\"O fields of this structure specify the range of bytes we wish to lock.
362 .\"O Bytes past the end of the file may be locked,
363 .\"O but not bytes before the start of the file.
364 ¤³¤Î¹½Â¤ÂΤÎ
365 .IR l_whence ", " l_start ", " l_len
366 ¥Õ¥£¡¼¥ë¥É¤Ç¡¢¥í¥Ã¥¯¤ò¹Ô¤¤¤¿¤¤¥Ð¥¤¥ÈÈϰϤò»ØÄꤹ¤ë¡£
367 ¥Õ¥¡¥¤¥ë¤ÎËöÈø¤è¤ê¸å¤í¤Î¥Ð¥¤¥È¤ò¥í¥Ã¥¯¤¹¤ë¤³¤È¤Ï¤Ç¤­¤ë¤¬¡¢
368 ¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤è¤êÁ°¤Î¥Ð¥¤¥È¤ò¥í¥Ã¥¯¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
369
370 .\"O .I l_start
371 .\"O is the starting offset for the lock, and is interpreted
372 .\"O relative to either:
373 .\"O the start of the file (if
374 .\"O .I l_whence
375 .\"O is
376 .\"O .BR SEEK_SET );
377 .\"O the current file offset (if
378 .\"O .I l_whence
379 .\"O is
380 .\"O .BR SEEK_CUR );
381 .\"O or the end of the file (if
382 .\"O .I l_whence
383 .\"O is
384 .\"O .BR SEEK_END ).
385 .\"O In the final two cases,
386 .\"O .I l_start
387 .\"O can be a negative number provided the
388 .\"O offset does not lie before the start of the file.
389 .I l_start
390 ¤Ï¥í¥Ã¥¯¤ò¹Ô¤¦Îΰè¤Î³«»Ï¥ª¥Õ¥»¥Ã¥È¤Ç¤¢¤ë¡£
391 ¤½¤Î°ÕÌ£¤Ï
392 .I l_whence
393 ¤Ë¤è¤ê°Û¤Ê¤ë:
394 .I l_whence
395 ¤¬
396 .B SEEK_SET
397 ¤Î¾ì¹ç¤Ï¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤«¤é¤Î¥ª¥Õ¥»¥Ã¥È¡¢
398 .I l_whence
399 ¤¬
400 .B SEEK_CUR
401 ¤Î¾ì¹ç¤Ï¸½ºß¤Î¥Õ¥¡¥¤¥ë¥ª¥Õ¥»¥Ã¥È¤«¤é¤Î¥ª¥Õ¥»¥Ã¥È¡¢
402 .I l_whence
403 ¤¬
404 .B SEEK_END
405 ¤Î¾ì¹ç¤Ï¥Õ¥¡¥¤¥ë¤ÎËöÈø¤«¤é¤Î¥ª¥Õ¥»¥Ã¥È¤È²ò¼á¤µ¤ì¤ë¡£
406 ¸å¤í¤Î£²¤Ä¤Î¾ì¹ç¤Ë¤Ï¡¢
407 ¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤è¤êÁ°¤Ë¤Ê¤é¤Ê¤¤ÈϰϤǡ¢
408 .I l_start
409 ¤ËÉé¤ÎÃͤò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
410
411 .\"O .I l_len
412 .\"O specifies the number of bytes to be locked.
413 .\"O If
414 .\"O .I l_len
415 .\"O is positive, then the range to be locked covers bytes
416 .\"O .I l_start
417 .\"O up to and including
418 .\"O .IR l_start + l_len \- 1 .
419 .\"O Specifying 0 for
420 .\"O .I l_len
421 .\"O has the special meaning: lock all bytes starting at the
422 .\"O location specified by
423 .\"O .IR l_whence " and " l_start
424 .\"O through to the end of file, no matter how large the file grows.
425 .I l_len
426 ¤Ï¥í¥Ã¥¯¤·¤¿¤¤¥Ð¥¤¥È¿ô¤ò¼¨¤¹¡£
427 .I l_len
428 ¤¬Àµ¤Î¾ì¹ç¡¢¥í¥Ã¥¯¤µ¤ì¤ë¥Ð¥¤¥ÈÈϰϤÏ
429 .I l_start
430 °Ê¾å
431 .IR l_start + l_len \- 1
432 °Ê²¼¤È¤Ê¤ë¡£
433 .I l_len
434 ¤Ë 0 ¤ò»ØÄꤷ¤¿¾ì¹ç¤ÏÆÃÊ̤ʰÕÌ£¤ò»ý¤Ä:
435 .IR l_whence " and " l_start
436 ¤Ç»ØÄꤵ¤ì¤ë°ÌÃÖ¤«¤é¥Õ¥¡¥¤¥ë¤ÎËöÈø¤Þ¤Ç¤ÎÁ´¤Æ¤Î¥Ð¥¤¥È¤ò¥í¥Ã¥¯¤¹¤ë
437 (¥Õ¥¡¥¤¥ë¤¬¤É¤ó¤Ê¤ËÂ礭¤¯¤Ê¤Ã¤¿¤È¤·¤Æ¤â¥Õ¥¡¥¤¥ë¤ÎËöÈø¤Þ¤Ç¥í¥Ã¥¯¤¹¤ë)¡£
438
439 .\"O POSIX.1-2001 allows (but does not require)
440 .\"O an implementation to support a negative
441 .\"O .I l_len
442 .\"O value; if
443 .\"O .I l_len
444 .\"O is negative, the interval described by
445 .\"O .I lock
446 .\"O covers bytes
447 .\"O .IR l_start + l_len
448 .\"O up to and including
449 .\"O .IR l_start \-1.
450 .\"O This is supported by Linux since kernel versions 2.4.21 and 2.5.49.
451 POSIX.1-2001 ¤Ç¤Ï¡¢Éé¤ÎÃͤÎ
452 .I l_len
453 ¤ò¥µ¥Ý¡¼¥È¤¹¤ë¼ÂÁõ¤òǧ¤á¤Æ¤¤¤ë (ɬ¿Ü¤Ç¤Ï¤Ê¤¤)¡£
454 .I l_len
455 ¤¬Éé¤Î¾ì¹ç¡¢¥í¥Ã¥¯¤µ¤ì¤ë¥Ð¥¤¥ÈÈϰϤÏ
456 .IR l_start + l_len
457 °Ê¾å
458 .IR l_start \-1
459 °Ê²¼¤È¤Ê¤ë¡£
460 ¤³¤ÎÆ°ºî¤Ï¥«¡¼¥Í¥ë 2.4.21 °Ê¹ß¤ª¤è¤Ó 2.5.49 °Ê¹ß¤Î Linux ¤Ç
461 ¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¡£
462
463 .\"O The
464 .\"O .I l_type
465 .\"O field can be used to place a read
466 .\"O .RB ( F_RDLCK )
467 .\"O or a write
468 .\"O .RB ( F_WRLCK )
469 .\"O lock on a file.
470 .\"O Any number of processes may hold a read lock (shared lock)
471 .\"O on a file region, but only one process may hold a write lock
472 .\"O (exclusive lock).
473 .\"O An exclusive lock excludes all other locks,
474 .\"O both shared and exclusive.
475 .I l_type
476 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Õ¥¡¥¤¥ë¤ËÂФ·¤ÆÆɤ߽Ф·¥í¥Ã¥¯
477 .RB ( F_RDLCK )
478 ¤È½ñ¤­¹þ¤ß¥í¥Ã¥¯
479 .RB ( F_WRLCK )
480 ¤Î¤É¤Á¤é¤ò
481 ÀßÄꤹ¤ë¤«¤ò»ØÄꤹ¤ë¡£
482 ¥Õ¥¡¥¤¥ë¤Î¤¢¤ëÎΰè¤ËÂФ·¤Æ¡¢Æɤ߽Ф·¥í¥Ã¥¯ (¶¦Í­¥í¥Ã¥¯) ¤òÊÝ»ý¤Ç¤­¤ë
483 ¥×¥í¥»¥¹¿ô¤ËÀ©¸Â¤Ï¤Ê¤¤¤¬¡¢½ñ¤­¹þ¤ß¥í¥Ã¥¯ (ÇÓ¾¥í¥Ã¥¯) ¤òÊÝ»ý¤Ç¤­¤ë
484 ¤Î¤Ï°ì¤Ä¤Î¥×¥í¥»¥¹¤À¤±¤Ç¤¢¤ë¡£ÇÓ¾¥í¥Ã¥¯¤òÀßÄꤹ¤ë¤È¡¢(¶¦Í­¥í¥Ã¥¯¤«
485 ÇÓ¾¥í¥Ã¥¯¤Ë¤«¤«¤ï¤é¤º) Â¾¤Î¥í¥Ã¥¯¤Ï²¿¤âÀßÄê¤Ç¤­¤Ê¤¤¡£
486 .\"O A single process can hold only one type of lock on a file region;
487 .\"O if a new lock is applied to an already-locked region,
488 .\"O then the existing lock is converted to the new lock type.
489 .\"O (Such conversions may involve splitting, shrinking, or coalescing with
490 .\"O an existing lock if the byte range specified by the new lock does not
491 .\"O precisely coincide with the range of the existing lock.)
492 °ì¤Ä¤Î¥×¥í¥»¥¹¤Ï¡¢¥Õ¥¡¥¤¥ë¤Î¤¢¤ëÎΰè¤ËÂФ·¤Æ°ì¼ïÎà¤Î¥í¥Ã¥¯¤·¤«ÊÝ»ý¤Ç¤­¤Ê¤¤¡£
493 ¿·µ¬¤Î¥í¥Ã¥¯¤¬¥í¥Ã¥¯¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ëÎΰè¤ËÂФ·¤ÆŬÍѤµ¤ì¤ë¤È¡¢´û¸¤Î¥í¥Ã¥¯
494 ¤Ï¿·µ¬¤Î¥í¥Ã¥¯¤Î¼ïÊ̤ËÊÑ´¹¤µ¤ì¤ë
495 (¿·µ¬¤Î¥í¥Ã¥¯¤Ç»ØÄꤵ¤ì¤¿¥Ð¥¤¥ÈÈϰϤ¬´û¸¥í¥Ã¥¯¤ÎÈϰϤȰìÃפ¹¤ë¾ì¹ç°Ê³°¤Ç¤Ï¡¢
496 ÊÑ´¹¤Î²áÄø¤Ç´û¸¤Î¥í¥Ã¥¯¤Îʬ³ä¡¢½Ì¾®¡¢·ë¹ç¤¬¹Ô¤ï¤ì¤ë¤³¤È¤¬¤¢¤ë)¡£
497 .TP
498 .BR F_SETLK " (\fIstruct flock *\fP)"
499 .\"O Acquire a lock (when
500 .\"O .I l_type
501 .\"O is
502 .\"O .B F_RDLCK
503 .\"O or
504 .\"O .BR F_WRLCK )
505 .\"O or release a lock (when
506 .\"O .I l_type
507 .\"O is
508 .\"O .BR F_UNLCK )
509 .\"O on the bytes specified by the
510 .\"O .IR l_whence ", " l_start ", and " l_len
511 .\"O fields of
512 .\"O .IR lock .
513 .RI ( l_type
514 ¤¬
515 .B F_RDLCK
516 ¤«
517 .B F_WRLCK
518 ¤Î¾ì¹ç¤Ï) ¥í¥Ã¥¯¤Î³ÍÆÀ¤ò¡¢
519 .RB ( F_UNLCK
520 ¤Î¾ì¹ç¤Ï) ¥í¥Ã¥¯¤Î²òÊü¤ò¡¢
521 .I flock
522 ¹½Â¤ÂΤΥե£¡¼¥ë¥É
523 .IR l_whence ", " l_start ", " l_len
524 ¤Ç»ØÄꤵ¤ì¤¿ÈϰϤΥХ¤¥È¤ËÂФ·¤Æ¹Ô¤¦¡£
525 .\"O If a conflicting lock is held by another process,
526 .\"O this call returns \-1 and sets
527 .\"O .I errno
528 .\"O to
529 .\"O .B EACCES
530 .\"O or
531 .\"O .BR EAGAIN .
532 »ØÄꤵ¤ì¤¿¥í¥Ã¥¯¤¬Â¾¤Î¥×¥í¥»¥¹¤¬ÀßÄꤷ¤Æ¤¤¤ë¥í¥Ã¥¯¤È¾×Æͤ¹¤ë¾ì¹ç¤Ï¡¢
533 \-1 ¤òÊÖ¤·¡¢
534 .I errno
535 ¤Ë
536 .B EACCES
537 ¤«
538 .B EAGAIN
539 ¤òÀßÄꤹ¤ë¡£
540 .TP
541 .BR F_SETLKW " (\fIstruct flock *\fP)"
542 .\"O As for
543 .\"O .BR F_SETLK ,
544 .\"O but if a conflicting lock is held on the file, then wait for that
545 .\"O lock to be released.
546 .B F_SETLK
547 ¤ÈƱÍͤÀ¤¬¡¢¤³¤Á¤é¤Ç¤Ï¤½¤Î¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ¾×Æͤ¹¤ë¥í¥Ã¥¯¤¬
548 ŬÍѤµ¤ì¤Æ¤¤¤¿¾ì¹ç¤Ë¡¢¤½¤Î¥í¥Ã¥¯¤¬²òÊü¤µ¤ì¤ë¤Î¤òÂÔ¤ÄÅÀ¤¬°Û¤Ê¤ë¡£
549 .\"O If a signal is caught while waiting, then the call is interrupted
550 .\"O and (after the signal handler has returned)
551 .\"O returns immediately (with return value \-1 and
552 .\"O .I errno
553 .\"O set to
554 .\"O .BR EINTR ;
555 .\"O see
556 .\"O .BR signal (7)).
557 ÂԤäƤ¤¤ë´Ö¤Ë¥·¥°¥Ê¥ë¤ò¼õ¤±¤¿¾ì¹ç¤Ï¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÏÃæÃǤµ¤ì¡¢
558 (¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤¬Ìá¤Ã¤¿Ä¾¸å¤Ë) ÊÖ¤êÃÍ \-1 ¤òÊÖ¤¹ (¤Þ¤¿
559 .I errno
560 ¤Ë
561 .B EINTR
562 ¤¬ÀßÄꤵ¤ì¤ë;
563 .BR signal (7)
564 »²¾È)¡£
565 .TP
566 .BR F_GETLK " (\fIstruct flock *\fP)"
567 .\"O On input to this call,
568 .\"O .I lock
569 .\"O describes a lock we would like to place on the file.
570 ¤³¤Î¥³¡¼¥ë¤Î¸Æ¤Ó½Ð¤·»þ¤Ë¤Ï¡¢
571 .I lock
572 ¤Ë¤Ï¤½¤Î¥Õ¥¡¥¤¥ë¤ËŬÍѤ·¤è¤¦¤È¤¹¤ë¥í¥Ã¥¯¤Ë´Ø¤¹¤ë¾ðÊó¤¬Æþ¤Ã¤Æ¤¤¤ë¡£
573 .\"O If the lock could be placed,
574 .\"O .BR fcntl ()
575 .\"O does not actually place it, but returns
576 .\"O .B F_UNLCK
577 .\"O in the
578 .\"O .I l_type
579 .\"O field of
580 .\"O .I lock
581 .\"O and leaves the other fields of the structure unchanged.
582 ¥í¥Ã¥¯¤òŬÍѤǤ­¤ë¾ì¹ç¤Ë¤Ï¡¢
583 .BR fcntl ()
584 ¤Ï¼ÂºÝ¤Ë¤Ï¥í¥Ã¥¯¤ò¹Ô¤ï¤º¡¢¹½Â¤ÂÎ
585 .I lock
586 ¤Î
587 .I l_type
588 ¥Õ¥£¡¼¥ë¥É¤Ë
589 .B F_UNLCK
590 ¤òÀßÄꤷ¡¢Â¾¤Î¥Õ¥£¡¼¥ë¥É¤ÏÊѹ¹¤»¤º¤Ë¡¢Éüµ¢¤¹¤ë¡£
591 .\"O If one or more incompatible locks would prevent
592 .\"O this lock being placed, then
593 .\"O .BR fcntl ()
594 .\"O returns details about one of these locks in the
595 .\"O .IR l_type ", " l_whence ", " l_start ", and " l_len
596 .\"O fields of
597 .\"O .I lock
598 .\"O and sets
599 .\"O .I l_pid
600 .\"O to be the PID of the process holding that lock.
601 °ã¤¦¼ïÊ̤Υí¥Ã¥¯¤¬ (°ì¤Ä¤â¤·¤¯¤ÏÊ£¿ô) Å¬ÍѤµ¤ì¤Æ¤¤¤Æ
602 ¥í¥Ã¥¯¤òŬÍѤǤ­¤Ê¤¤¤è¤¦¤Ê¾ì¹ç¤Ë¤Ï¡¢
603 .BR fcntl ()
604 ¤Ï¡¢¸¶°ø¤È¤Ê¤Ã¤¿¥í¥Ã¥¯¤Î°ì¤Ä¤Ë¤Ä¤¤¤Æ¤Î¾ÜºÙ¾ðÊó¤ò¹½Â¤ÂÎ
605 .I lock
606 ¤Î¥Õ¥£¡¼¥ë¥É
607 .IR l_type ", " l_whence ", " l_start ", " l_len
608 ¤Ë³ÊǼ¤·¡¢¤Þ¤¿
609 .I l_pid
610 ¤Ë¥í¥Ã¥¯¤òÊÝ»ý¤·¤Æ¤¤¤ë¥×¥í¥»¥¹¤Î PID ¤òÀßÄꤷ¤Æ¡¢Éüµ¢¤¹¤ë¡£
611 .P
612 .\"O In order to place a read lock,
613 .\"O .I fd
614 .\"O must be open for reading.
615 .\"O In order to place a write lock,
616 .\"O .I fd
617 .\"O must be open for writing.
618 .\"O To place both types of lock, open a file read-write.
619 Æɤ߽Ф·¥í¥Ã¥¯¤òŬÍѤ¹¤ë¤Ë¤Ï¡¢
620 .I fd
621 ¤ÏÆɤ߽Ф·ÍѤ˥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
622 ½ñ¤­¹þ¤ß¥í¥Ã¥¯¤òŬÍѤ¹¤ë¤Ë¤Ï¡¢
623 .I fd
624 ¤Ï½ñ¤­¹þ¤ßÍѤ˥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
625 Æɤ߽ñ¤­Î¾Êý¤Î¥í¥Ã¥¯¤òŬÍѤ¹¤ë¤Ë¤Ï¡¢Æɤ߽ñ¤­Î¾ÍѤÇ
626 ¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
627 .P
628 .\"O As well as being removed by an explicit
629 .\"O .BR F_UNLCK ,
630 .\"O record locks are automatically released when the process
631 .\"O terminates or if it closes
632 .\"O .I any
633 .\"O file descriptor referring to a file on which locks are held.
634 ¥ì¥³¡¼¥É¤Î¥í¥Ã¥¯¤Ï¡¢
635 .B F_UNLCK
636 ¤Ë¤è¤êÌÀ¼¨Åª¤Ëºï½ü¤µ¤ì¤ë¤À¤±¤Ç¤Ê¤¯¡¢
637 ¥×¥í¥»¥¹¤¬½ªÎ»¤·¤¿¤È¤­¤ä¡¢¥í¥Ã¥¯¤¬Å¬ÍѤµ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Æ¤¤¤ë
638 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¤¤¤º¤ì¤«¤¬¥¯¥í¡¼¥º¤µ¤ì¤¿¾ì¹ç¤Ë¤â²òÊü¤µ¤ì¤ë¡£
639 ¤³¤Î¥í¥Ã¥¯¤Î²òÊü¤Ï¼«Æ°Åª¤Ë¹Ô¤ï¤ì¤ë¡£
640 .\"O .\" (Additional file descriptors referring to the same file
641 .\"O .\" may have been obtained by calls to
642 .\"O .\" .BR open "(2), " dup "(2), " dup2 "(2), or " fcntl ().)
643 .\" .RB ( open "(2), " dup "(2), " dup2 "(2), " fcntl ()
644 .\" ¤Î¸Æ¤Ó½Ð¤·¤Ë¤è¤Ã¤ÆƱ¤¸¥Õ¥¡¥¤¥ë¤ò»²¾È¤¹¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬
645 .\" Â¾¤Ë¤â¤Ç¤­¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤)
646 .\"O This is bad: it means that a process can lose the locks on
647 .\"O a file like
648 .\"O .I /etc/passwd
649 .\"O or
650 .\"O .I /etc/mtab
651 .\"O when for some reason a library function decides to open, read
652 .\"O and close it.
653 ¤³¤ÎÆ°ºî¤Ï¤Þ¤º¤¤: ¤¢¤ë¥×¥í¥»¥¹¤¬
654 .I /etc/passwd
655 ¤ä
656 .I /etc/mtab
657 ¤È¤¤¤Ã¤¿¥Õ¥¡¥¤¥ë¤Ë¥í¥Ã¥¯¤òŬÍѤ·¤Æ¤¤¤ë¤È¤­¤Ë¡¢
658 ¤¢¤ë¥é¥¤¥Ö¥é¥ê´Ø¿ô¤¬²¿¤«¤ÎÍýͳ¤ÇƱ¤¸¥Õ¥¡¥¤¥ë¤ò open, read, close
659 ¤¹¤ë¤È¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î¥í¥Ã¥¯¤¬¼º¤ï¤ì¤ë¤³¤È¤Ë¤Ê¤ë¡£
660 .P
661 .\"O Record locks are not inherited by a child created via
662 .\"O .BR fork (2),
663 .\"O but are preserved across an
664 .\"O .BR execve (2).
665 ¥ì¥³¡¼¥É¤Î¥í¥Ã¥¯¤Ï
666 .BR fork (2)
667 ¤ÇºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ë¤Ï·Ñ¾µ¤µ¤ì¤Ê¤¤¤¬¡¢
668 .BR execve (2)
669 ¤ÎÁ°¸å¤Ç¤ÏÊݸ¤µ¤ì¤ë¡£
670 .P
671 .\"O Because of the buffering performed by the
672 .\"O .BR stdio (3)
673 .\"O library, the use of record locking with routines in that package
674 .\"O should be avoided; use
675 .\"O .BR read (2)
676 .\"O and
677 .\"O .BR write (2)
678 .\"O instead.
679 .BR stdio (3)
680 ¤Ç¤Ï¥Ð¥Ã¥Õ¥¡¥ê¥ó¥°¤¬¹Ô¤ï¤ì¤ë¤Î¤Ç¡¢
681 stdio ´ØÏ¢¤Î´Ø¿ô¤Ç¤Ï¥ì¥³¡¼¥É¤Î¥í¥Ã¥¯¤Î»ÈÍѤϲóÈò¤µ¤ì¤ë;
682 Âå¤ï¤ê¤Ë
683 .BR read (2)
684 ¤ä
685 .BR write (2)
686 ¤ò»ÈÍѤ¹¤ë¤³¤È¡£
687 .\"O .SS "Mandatory locking"
688 .SS "¶¯À©¥í¥Ã¥¯ (mandatory locking)"
689 .\"O (Non-POSIX.)
690 .\"O The above record locks may be either advisory or mandatory,
691 .\"O and are advisory by default.
692 ¾å½Ò¤Î¥í¥Ã¥¯¤Ë¤Ï¥¢¥É¥Ð¥¤¥¶¥ê¡¦¥í¥Ã¥¯ (advisory lock) ¤È¶¯À©¥í¥Ã¥¯ (mandatory
693 lock) ¤ÎÆó¼ïÎब¤¢¤ë¤¬¡¢¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¥¢¥É¥Ð¥¤¥¶¥ê¡¦¥í¥Ã¥¯¤È¤Ê¤ë¡£
694
695 .\"O Advisory locks are not enforced and are useful only between
696 .\"O cooperating processes.
697 ¥¢¥É¥Ð¥¤¥¶¥ê¡¦¥í¥Ã¥¯¤Ë¶¯À©ÎϤϤʤ¯¡¢¶¨Ä´¤·¤ÆÆ°ºî¤¹¤ë¥×¥í¥»¥¹´Ö¤Ç¤Î¤ß
698 Í­¸ú¤Ç¤¢¤ë¡£
699
700 .\"O Mandatory locks are enforced for all processes.
701 ¶¯À©¥í¥Ã¥¯¤ÏÁ´¤Æ¤Î¥×¥í¥»¥¹¤ËÂФ·¤Æ¸ú²Ì¤¬¤¢¤ë¡£
702 .\"O If a process tries to perform an incompatible access (e.g.,
703 .\"O .BR read (2)
704 .\"O or
705 .\"O .BR write (2))
706 .\"O on a file region that has an incompatible mandatory lock,
707 .\"O then the result depends upon whether the
708 .\"O .B O_NONBLOCK
709 .\"O flag is enabled for its open file description.
710 .\"O If the
711 .\"O .B O_NONBLOCK
712 .\"O flag is not enabled, then
713 .\"O system call is blocked until the lock is removed
714 .\"O or converted to a mode that is compatible with the access.
715 .\"O If the
716 .\"O .B O_NONBLOCK
717 .\"O flag is enabled, then the system call fails with the error
718 .\"O .BR EAGAIN .
719 ¤¢¤ë¥×¥í¥»¥¹¤¬¸ß´¹À­¤Î¤Ê¤¤¶¯À©¥í¥Ã¥¯¤¬Å¬ÍѤµ¤ì¤¿¥Õ¥¡¥¤¥ëÎΰè¤ËÂФ·¤Æ
720 .RB ( read (2)
721 ¤ä
722 .BR write (2)
723 ¤Ë¤è¤ê) ¸ß´¹À­¤Î¤Ê¤¤¥¢¥¯¥»¥¹¤ò¼Â¹Ô¤·¤è¤¦¤È¤·¤¿¾ì¹ç¡¢
724 ¥¢¥¯¥»¥¹¤Î·ë²Ì¤Ï
725 ¤½¤Î¥Õ¥¡¥¤¥ë¤Î¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ëµ­½Ò¤Ç
726 .B O_NONBLOCK
727 ¥Õ¥é¥°¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤«¤Ë¤è¤ê·è¤Þ¤ë¡£
728 .B O_NONBLOCK
729 ¥Õ¥é¥°¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤¤¤È¤­¤Ï¡¢¥í¥Ã¥¯¤¬ºï½ü¤µ¤ì¤ë¤«¡¢
730 ¥í¥Ã¥¯¤¬¥¢¥¯¥»¥¹¤È¸ß´¹À­¤Î¤¢¤ë¥â¡¼¥É¤ËÊÑ´¹¤µ¤ì¤ë¤Þ¤Ç¡¢
731 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÏÄä»ß (block) ¤µ¤ì¤ë¡£
732 .B O_NONBLOCK
733 ¥Õ¥é¥°¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤È¤­¤Ï¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¥¨¥é¡¼
734 .B EAGAIN
735 ¤Ç¼ºÇÔ¤¹¤ë¡£
736
737 .\"O To make use of mandatory locks, mandatory locking must be enabled
738 .\"O both on the file system that contains the file to be locked,
739 .\"O and on the file itself.
740 .\"O Mandatory locking is enabled on a file system
741 .\"O using the "\-o mand" option to
742 .\"O .BR mount (8),
743 .\"O or the
744 .\"O .B MS_MANDLOCK
745 .\"O flag for
746 .\"O .BR mount (2).
747 .\"O Mandatory locking is enabled on a file by disabling
748 .\"O group execute permission on the file and enabling the set-group-ID
749 .\"O permission bit (see
750 .\"O .BR chmod (1)
751 .\"O and
752 .\"O .BR chmod (2)).
753 ¶¯À©¥í¥Ã¥¯¤ò»ÈÍѤ¹¤ë¤¿¤á¤Ë¤Ï¡¢¥í¥Ã¥¯ÂоݤΥե¡¥¤¥ë¤¬´Þ¤Þ¤ì¤ë¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à
754 ¤È¡¢¥í¥Ã¥¯ÂоݤΥե¡¥¤¥ë¼«¿È¤ÎξÊý¤Ë¤Ä¤¤¤Æ¡¢¶¯À©¥í¥Ã¥¯¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤±¤ì
755 ¤Ð¤Ê¤é¤Ê¤¤¡£¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ë¤Ä¤¤¤Æ¶¯À©¥í¥Ã¥¯¤òÍ­¸ú¤Ë¤¹¤ë¤Ë¤Ï¡¢
756 .BR mount (8)
757 ¤Ë "\-o mand" ¥ª¥×¥·¥ç¥ó¤òÅϤ¹¤«¡¢
758 .BR mount (2)
759 ¤Ë
760 .B MS_MANDLOCK
761 ¥Õ¥é¥°¤ò»ØÄꤹ¤ë¡£¥Õ¥¡¥¤¥ë¤Ë¤Ä¤¤¤Æ¶¯À©¥í¥Ã¥¯¤òÍ­¸ú¤Ë¤¹¤ë¤Ë¤Ï¡¢
762 ¤½¤Î¥Õ¥¡¥¤¥ë¤Î¥°¥ë¡¼¥×¼Â¹Ôµö²Ä (group execute permission) ¤ò̵¸ú¤È¤·¡¢
763 ¤«¤Ä set-group-ID µö²Ä¥Ó¥Ã¥È¤òÍ­¸ú¤Ë¤¹¤ë
764 .RB ( chmod (1)
765 ¤È
766 .BR chmod (2)
767 ¤ò»²¾È)¡£
768
769 .\"O The Linux implementation of mandatory locking is unreliable.
770 .\"O See BUGS below.
771 Linux ¤Î¶¯À©¥í¥Ã¥¯¤Î¼ÂÁõ¤Ï¿®ÍêÀ­¤Ë·ç¤±¤ë¤â¤Î¤Ç¤¢¤ë¡£
772 ²¼µ­¤Î¡Ö¥Ð¥°¡×¤ÎÀá¤ò»²¾È¤Î¤³¤È¡£
773 .\"O .SS "Managing signals"
774 .SS "¥·¥°¥Ê¥ë¤Î´ÉÍý"
775 .\"O .BR F_GETOWN ,
776 .\"O .BR F_SETOWN ,
777 .\"O .BR F_GETOWN_EX ,
778 .\"O .BR F_SETOWN_EX ,
779 .\"O .BR F_GETSIG
780 .\"O and
781 .\"O .B F_SETSIG
782 .\"O are used to manage I/O availability signals:
783 .BR F_GETOWN ,
784 .BR F_SETOWN ,
785 .BR F_GETOWN_EX ,
786 .BR F_SETOWN_EX ,
787 .BR F_GETSIG ,
788 .B F_SETSIG
789 ¤Ï¡¢I/O ¤¬ÍøÍѲÄǽ¤Ë¤Ê¤Ã¤¿¤³¤È¤ò¼¨¤¹¥·¥°¥Ê¥ë¤ò´ÉÍý¤¹¤ë¤¿¤á¤Ë»ÈÍѤµ¤ì¤ë¡£
790 .TP
791 .BR F_GETOWN " (\fIvoid\fP)"
792 .\"O Return (as the function result)
793 .\"O the process ID or process group currently receiving
794 .\"O .B SIGIO
795 .\"O and
796 .\"O .B SIGURG
797 .\"O signals for events on file descriptor
798 .\"O .IR fd .
799 .\"O Process IDs are returned as positive values;
800 .\"O process group IDs are returned as negative values (but see BUGS below).
801 .\"O .I arg
802 .\"O is ignored.
803 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
804 .I fd
805 ¤Î¥¤¥Ù¥ó¥È¤ËÂФ¹¤ë¥·¥°¥Ê¥ë
806 .B SIGIO
807 ¤ª¤è¤Ó
808 .B SIGURG
809 ¤ò¼õ¤±¤Æ¤¤¤ë¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ID ¤«¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ò
810 (´Ø¿ô¤Î·ë²Ì¤È¤·¤Æ) ÊÖ¤¹¡£
811 ¥×¥í¥»¥¹ID ¤ÏÀµ¤ÎÃͤȤ·¤ÆÊÖ¤µ¤ì¤ë¡£
812 ¥×¥í¥»¥¹¥°¥ë¡¼¥×ID ¤ÏÉé¤ÎÃͤȤ·¤ÆÊÖ¤µ¤ì¤ë (²¼µ­¤Î¥Ð¥°¤Î¾Ï¤ò»²¾È)¡£
813 .I arg
814 ¤Ï̵»ë¤µ¤ì¤ë¡£
815 .TP
816 .BR F_SETOWN " (\fIlong\fP)"
817 .\"O Set the process ID or process group ID that will receive
818 .\"O .B SIGIO
819 .\"O and
820 .\"O .B SIGURG
821 .\"O signals for events on file descriptor
822 .\"O .IR fd
823 .\"O to the ID given in
824 .\"O .IR arg .
825 .\"O A process ID is specified as a positive value;
826 .\"O a process group ID is specified as a negative value.
827 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
828 .I fd
829 ¤Î¥¤¥Ù¥ó¥ÈȯÀ¸¤òÃΤ餻¤ë¥·¥°¥Ê¥ë
830 .B SIGIO
831 ¤ä
832 .B SIGURG
833 ¤ò¼õ¤±¤ë¥×¥í¥»¥¹¤Î
834 ¥×¥í¥»¥¹ ID ¤Þ¤¿¤Ï¥×¥í¥»¥¹¥°¥ë¡¼¥×ID ¤ò
835 .I arg
836 ¤Ç»ØÄꤵ¤ì¤¿ ID ¤ËÀßÄꤹ¤ë¡£
837 ¥×¥í¥»¥¹ID ¤ÏÀµ¤ÎÃͤȤ·¤Æ»ØÄꤷ¡¢
838 ¥×¥í¥»¥¹¥°¥ë¡¼¥×ID ¤ÏÉé¤ÎÃͤȤ·¤Æ»ØÄꤹ¤ë¡£
839 .\"O Most commonly, the calling process specifies itself as the owner
840 .\"O (that is,
841 .\"O .I arg
842 .\"O is specified as
843 .\"O .BR getpid (2)).
844 ¤Û¤È¤ó¤É¤Î¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Ï½êÍ­¼Ô¤È¤·¤Æ¼«Ê¬¼«¿È¤ò»ØÄꤹ¤ë
845 (¤Ä¤Þ¤ê
846 .I arg
847 ¤Ë
848 .BR getpid (2)
849 ¤ò»ØÄꤹ¤ë)¡£
850
851 .\"O .\" From glibc.info:
852 .\" glibc.info ¤è¤ê:
853 .\"O If you set the
854 .\"O .B O_ASYNC
855 .\"O status flag on a file descriptor by using the
856 .\"O .B F_SETFL
857 .\"O command of
858 .\"O .BR fcntl (),
859 .\"O a
860 .\"O .B SIGIO
861 .\"O signal is sent whenever input or output becomes possible
862 .\"O on that file descriptor.
863 .\"O .B F_SETSIG
864 .\"O can be used to obtain delivery of a signal other than
865 .\"O .BR SIGIO .
866 .BR fcntl ()
867 ¤Î
868 .B F_SETFL
869 ¥³¥Þ¥ó¥É¤ò»ÈÍѤ·¤Æ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë
870 .B O_ASYNC
871 ¾õÂ֥ե饰¤òÀßÄꤷ¤¿¾ì¹ç¤Ë¤Ï¡¢¤½¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ø¤Î
872 Æþ½ÐÎϤ¬²Äǽ¤Ë¤Ê¤ëÅÙ¤Ë
873 .B SIGIO
874 ¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¡£
875 .B F_SETSIG
876 ¤Ï
877 .B SIGIO
878 °Ê³°¤ÎÊ̤Υ·¥°¥Ê¥ë¤ÎÇÛÁ÷¤ò¼õ¤±¤é¤ì¤ë¤è¤¦¤Ë
879 ¤¹¤ë¤Î¤Ë¤â»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
880 .\"O If this permission check fails, then the signal is
881 .\"O silently discarded.
882 µö²Ä (permission) ¤Î¥Á¥§¥Ã¥¯¤Ç¼ºÇÔ¤·¤¿¾ì¹ç¤Ë¤Ï¡¢
883 ¥·¥°¥Ê¥ë¤ÏÌۤäƼΤƤé¤ì¤ë¡£
884
885 .\"O Sending a signal to the owner process (group) specified by
886 .\"O .B F_SETOWN
887 .\"O is subject to the same permissions checks as are described for
888 .\"O .BR kill (2),
889 .\"O where the sending process is the one that employs
890 .\"O .B F_SETOWN
891 .\"O (but see BUGS below).
892 .B F_SETOWN
893 ¤Ë¤è¤ê»ØÄꤵ¤ì¤¿½êÍ­¼Ô¤Î¥×¥í¥»¥¹ (¤Þ¤¿¤Ï¥×¥í¥»¥¹¥°¥ë¡¼¥×) ¤Ë
894 ¥·¥°¥Ê¥ë¤òÁ÷¤ëºÝ¤Ë¤Ï¡¢
895 .BR kill (2)
896 ¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¤Î¤ÈƱ¤¸µö²Ä¤Î¥Á¥§¥Ã¥¯¤¬¹Ô¤ï¤ì¤ë¡£
897 ¤³¤Î¤È¤­¡¢¥·¥°¥Ê¥ë¤òÁ÷¿®¤¹¤ë¥×¥í¥»¥¹¤Ï
898 .B F_SETOWN
899 ¤ò»È¤Ã¤¿¥×¥í¥»¥¹¤Ç¤¢¤ë
900 (⤷¡¢²¼µ­¤Î¡Ö¥Ð¥°¡×¤Î¾Ï¤ò»²¾È¤Î¤³¤È)¡£
901
902 .\"O If the file descriptor
903 .\"O .I fd
904 .\"O refers to a socket,
905 .\"O .B F_SETOWN
906 .\"O also selects
907 .\"O the recipient of
908 .\"O .B SIGURG
909 .\"O signals that are delivered when out-of-band
910 .\"O data arrives on that socket.
911 .\"O .RB ( SIGURG
912 .\"O is sent in any situation where
913 .\"O .BR select (2)
914 .\"O would report the socket as having an "exceptional condition".)
915 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬¥½¥±¥Ã¥È¤ò»²¾È¤·¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢
916 .B F_SETOWN
917 ¤ò»ÈÍѤ·¤Æ¡¢¥½¥±¥Ã¥È¤ËÂÓ°è³° (out-of-band) ¥Ç¡¼¥¿¤¬ÆϤ¤¤¿»þ¤Ë
918 .B SIGURG
919 ¥·¥°¥Ê¥ë¤òÇÛÁ÷¤¹¤ëÁê¼ê¤òÁªÂò¤¹¤ë¤³¤È¤â¤Ç¤­¤ë
920 .RB ( SIGURG
921 ¤¬Á÷¤é¤ì¤¿¾ì¹ç¤Ë¤Ï
922 .BR select (2)
923 ¤¬¥½¥±¥Ã¥È¤¬¡ÖÆÃÊ̤ʾõÂ֡פˤ¢¤ë¤ÈÊó¹ð¤¹¤ë¤³¤È¤À¤í¤¦)¡£
924 .\"O .\" The following appears to be rubbish.  It doesn't seem to
925 .\"O .\" be true according to the kernel source, and I can write
926 .\"O .\" a program that gets a terminal-generated SIGIO even though
927 .\"O .\" it is not the foreground process group of the terminal.
928 .\"O .\" -- MTK, 8 Apr 05
929 .\"O .\"
930 .\"O .\" If the file descriptor
931 .\"O .\" .I fd
932 .\"O .\" refers to a terminal device, then SIGIO
933 .\"O .\" signals are sent to the foreground process group of the terminal.
934 .\" °Ê²¼¤Îµ­½Ò¤Ï¥´¥ß¤À¤í¤¦¡£
935 .\" ¥«¡¼¥Í¥ë¥½¡¼¥¹¤ò¸«¤ë¤È¤³¤Îµ­½Ò¤Ï´Ö°ã¤Ã¤Æ¤¤¤ë¤è¤¦¤À¤·¡¢
936 .\" ¥×¥í¥°¥é¥à¤ò½ñ¤¤¤Æ¤ß¤¿¤È¤³¤í¡¢Ã¼Ëö¤Î¥Õ¥©¥¢¥°¥é¥ó¥É¡¦¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ç
937 .\" ¤Ê¤¯¤Æ¤â¡¢Ã¼Ëö¤¬À¸À®¤·¤¿ SIGIO ¥·¥°¥Ê¥ë¤ò¼õ¤±¤È¤ë¡£
938 .\" -- MTK, 8 Apr 05
939 .\"
940 .\" ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬Ã¼Ëö¥Ç¥Ð¥¤¥¹¤ò»²¾È¤·¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
941 .\" SIGIO ¥·¥°¥Ê¥ë¤Ï¤½¤ÎüËö¤Î¥Õ¥©¥¢¥°¥é¥ó¥É¡¦¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ø¤ÈÁ÷¤é¤ì¤ë¡£
942
943 .\"O The following was true in 2.6.x kernels up to and including
944 .\"O kernel 2.6.11:
945 ¥Ð¡¼¥¸¥ç¥ó 2.6.11 °ÊÁ°¤Î 2.6.x ¥«¡¼¥Í¥ë¤Ç¤Ï¡¢°Ê²¼¤Ë¼¨¤¹Æ°ºî¤Ç¤¢¤Ã¤¿¡£
946 .RS
947 .IP
948 .\"O If a nonzero value is given to
949 .\"O .B F_SETSIG
950 .\"O in a multithreaded process running with a threading library
951 .\"O that supports thread groups (e.g., NPTL),
952 .\"O then a positive value given to
953 .\"O .B F_SETOWN
954 .\"O has a different meaning:
955 .\"O .\" The relevant place in the (2.6) kernel source is the
956 .\"O .\" 'switch' in fs/fcntl.c::send_sigio_to_task() -- MTK, Apr 2005
957 .\"O instead of being a process ID identifying a whole process,
958 .\"O it is a thread ID identifying a specific thread within a process.
959 ¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¥¹¥ì¥Ã¥É¥é¥¤¥Ö¥é¥ê (Î㤨¤Ð NPTL) ¤ò
960 »È¤Ã¤ÆÆ°ºî¤·¤Æ¤¤¤ë¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¡¦¥×¥í¥»¥¹¤Ç
961 .B F_SETSIG
962 ¤Ë 0 °Ê³°¤ÎÃͤò»ØÄꤷ¤¿¾ì¹ç¡¢
963 .B F_SETOWN
964 ¤ËÀµ¤ÎÃͤòÅϤ¹¤È¡¢¤½¤Î°ÕÌ£¤¬°ã¤Ã¤Æ¤¯¤ë:
965 .\" The relevant place in the (2.6) kernel source is the
966 .\" 'switch' in fs/fcntl.c::send_sigio_to_task() -- MTK, Apr 2005
967 ¥×¥í¥»¥¹Á´ÂΤò¼¨¤¹¥×¥í¥»¥¹ID ¤Ç¤Ï¤Ê¤¯¡¢¥×¥í¥»¥¹Æâ¤ÎÆÃÄê¤Î
968 ¥¹¥ì¥Ã¥É¤ò¼¨¤¹¥¹¥ì¥Ã¥ÉID ¤È²ò¼á¤µ¤ì¤ë¡£
969 .\"O Consequently, it may be necessary to pass
970 .\"O .B F_SETOWN
971 .\"O the result of
972 .\"O .BR gettid (2)
973 .\"O instead of
974 .\"O .BR getpid (2)
975 .\"O to get sensible results when
976 .\"O .B F_SETSIG
977 .\"O is used.
978 ¤·¤¿¤¬¤Ã¤Æ¡¢
979 .B F_SETSIG
980 ¤ò»È¤¦¾ì¹ç¤Ë¤Ï¡¢¤­¤Á¤ó¤È·ë²Ì¤ò¼õ¤±¼è¤ë¤Ë¤Ï¡¢
981 .B F_SETOWN
982 ¤ËÅϤ¹Ãͤò
983 .BR getpid (2)
984 ¤Ç¤Ï¤Ê¤¯
985 .BR gettid (2)
986 ¤ÎÊÖ¤êÃͤˤ¹¤ëɬÍפ¬¤¢¤ë¤À¤í¤¦¡£
987 .\"O (In current Linux threading implementations,
988 .\"O a main thread's thread ID is the same as its process ID.
989 .\"O This means that a single-threaded program can equally use
990 .\"O .BR gettid (2)
991 .\"O or
992 .\"O .BR getpid (2)
993 .\"O in this scenario.)
994 (¸½¾õ¤Î Linux ¥¹¥ì¥Ã¥É¼ÂÁõ¤Ç¤Ï¡¢¥á¥¤¥ó¡¦¥¹¥ì¥Ã¥É¤Î¥¹¥ì¥Ã¥ÉID ¤Ï
995 ¤½¤Î¥¹¥ì¥Ã¥É¤Î¥×¥í¥»¥¹ID ¤ÈƱ¤¸¤Ç¤¢¤ë¡£¤Ä¤Þ¤ê¡¢
996 ¥·¥°¥Ê¥ë¡¦¥¹¥ì¥Ã¥É¤Î¥×¥í¥°¥é¥à¤Ç¤Ï¤³¤Î¾ì¹ç
997 .BR gettid (2)
998 ¤È
999 .BR getpid (2)
1000 ¤ÏÁ´¤¯Æ±¤¸¤è¤¦¤Ë»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£)
1001 .\"O Note, however, that the statements in this paragraph do not apply
1002 .\"O to the
1003 .\"O .B SIGURG
1004 .\"O signal generated for out-of-band data on a socket:
1005 .\"O this signal is always sent to either a process or a process group,
1006 .\"O depending on the value given to
1007 .\"O .BR F_SETOWN .
1008 .\"O .\" send_sigurg()/send_sigurg_to_task() bypasses
1009 .\"O .\" kill_fasync()/send_sigio()/send_sigio_to_task()
1010 .\"O .\" to directly call send_group_sig_info()
1011 .\"O .\"        -- MTK, Apr 2005 (kernel 2.6.11)
1012 ¤¿¤À¤·¡¢Ãí°Õ¤¹¤Ù¤­ÅÀ¤È¤·¤Æ¡¢¤³¤ÎÃÊÍî¤Ç½Ò¤Ù¤¿¤³¤È¤Ï¡¢
1013 ¥½¥±¥Ã¥È¤ÎÂÓ°è³°¥Ç¡¼¥¿¤¬ÆϤ¤¤¿¤È¤­¤ËÀ¸À®¤µ¤ì¤ë
1014 .B SIGURG
1015 ¥·¥°¥Ê¥ë¤Ë¤Ï¤¢¤Æ¤Ï¤Þ¤é¤Ê¤¤¡£
1016 ¤³¤Î¥·¥°¥Ê¥ë¤Ï¾ï¤Ë¥×¥í¥»¥¹¤«¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ËÁ÷¤é¤ì¡¢
1017 Á÷¿®Àè¤Ï
1018 .B F_SETOWN
1019 ¤ËÅϤµ¤ì¤¿Ãͤˤ·¤¿¤¬¤Ã¤Æ·è¤á¤é¤ì¤ë¡£
1020 .\" send_sigurg()/send_sigurg_to_task() bypasses
1021 .\" kill_fasync()/send_sigio()/send_sigio_to_task()
1022 .\" to directly call send_group_sig_info()
1023 .\"     -- MTK, Apr 2005 (kernel 2.6.11)
1024 .RE
1025 .IP
1026 .\"O The above behavior was accidentally dropped in Linux 2.6.12,
1027 .\"O and won't be restored.
1028 .\"O From Linux 2.6.32 onwards, use
1029 .\"O .BR F_SETOWN_EX
1030 .\"O to target
1031 .\"O .B SIGIO
1032 .\"O and
1033 .\"O .B SIGURG
1034 .\"O signals at a particular thread.
1035 ¾åµ­¤ÎÆ°ºî¤Ï¡¢Linux 2.6.12 ¤Ç¿Þ¤é¤º¤âºï½ü¤µ¤ì¡¢
1036 ¸µ¤ËÌᤵ¤ì¤Ê¤¤Í½Äê¤Ç¤¢¤ë¡£
1037 Linux 2.6.32 °Ê¹ß¤Ç¡¢ÆÃÄê¤Î¥¹¥ì¥Ã¥É°¸¤Ë¥·¥°¥Ê¥ë
1038 .B SIGIO
1039 ¤È
1040 .B SIGURG
1041 ¤òÁ÷¤ë¤Ë¤Ï
1042 .B F_SETOWN_EX
1043 ¤ò»È¤¦¤³¤È¡£
1044 .TP
1045 .\"O .BR F_GETOWN_EX " (struct f_owner_ex *) (since Linux 2.6.32)"
1046 .BR F_GETOWN_EX " (struct f_owner_ex *) (Linux 2.6.32 °Ê¹ß)"
1047 .\"O Return the current file descriptor owner settings
1048 .\"O as defined by a previous
1049 .\"O .BR F_SETOWN_EX
1050 .\"O operation.
1051 .\"O The information is returned in the structure pointed to by
1052 .\"O .IR arg ,
1053 .\"O which has the following form:
1054 ľÁ°¤Î
1055 .B F_SETOWN_EX
1056 Áàºî¤ÇÄêµÁ¤µ¤ì¤¿¸½ºß¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î½êÍ­¼ÔÀßÄê
1057 ¤òÊÖ¤¹¡£¾ðÊó¤Ï
1058 .I arg
1059 ¤¬»Ø¤¹¹½Â¤ÂΤ˳ÊǼ¤µ¤ì¤ÆÊÖ¤µ¤ì¤ë¡£¹½Â¤ÂΤϰʲ¼¤ÎÄ̤ê¤Ç¤¢¤ë¡£
1060 .nf
1061 .in +4n
1062
1063 struct f_owner_ex {
1064     int   type;
1065     pid_t pid;
1066 };
1067
1068 .in
1069 .fi
1070 .\"O The
1071 .\"O .I type
1072 .\"O field will have one of the values
1073 .\"O .BR F_OWNER_TID ,
1074 .\"O .BR F_OWNER_PID ,
1075 .\"O or
1076 .\"O .BR F_OWNER_PGRP .
1077 .I type
1078 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢
1079 .B F_OWNER_TID ,
1080 .B F_OWNER_PID ,
1081 .B F_OWNER_PGRP
1082 ¤Î¤¤¤º¤ì¤«°ì¤Ä¤ÎÃͤȤʤ롣
1083 .\"O The
1084 .\"O .I pid
1085 .\"O field is a positive integer representing a thread ID, process ID,
1086 .\"O or process group ID.
1087 .\"O See
1088 .\"O .B F_SETOWN_EX
1089 .\"O for more details.
1090 .I pid
1091 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥¹¥ì¥Ã¥É ID¡¢¥×¥í¥»¥¹ ID¡¢¥×¥í¥»¥¹¥°¥ë¡¼¥× ID ¤ò
1092 ɽ¤¹Àµ¤ÎÀ°¿ô¤Ç¤¢¤ë¡£¾ÜºÙ¤Ï
1093 .B F_SETOWN_EX
1094 ¤ò»²¾È¡£
1095 .TP
1096 .\"O .BR F_SETOWN_EX " (struct f_owner_ex *) (since Linux 2.6.32)"
1097 .BR F_SETOWN_EX " (struct f_owner_ex *) (Linux 2.6.32 °Ê¹ß)"
1098 .\"O This operation performs a similar task to
1099 .\"O .BR F_SETOWN .
1100 .\"O It allows the caller to direct I/O availability signals
1101 .\"O to a specific thread, process, or process group.
1102 ¤³¤ÎÁàºî¤Ï
1103 .B F_SETOWN
1104 ¤ÈƱÍͤνèÍý¤ò¹Ô¤¦¡£
1105 ¤³¤ÎÁàºî¤ò»È¤¦¤È¡¢I/O ¤¬ÍøÍѲÄǽ¤Ë¤Ê¤Ã¤¿¤³¤È¤ò¼¨¤¹¥·¥°¥Ê¥ë¤ò¡¢
1106 ÆÃÄê¤Î¥¹¥ì¥Ã¥É¡¢¥×¥í¥»¥¹¡¢¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ËÁ÷¤ë¤³¤È¤¬¤Ç¤­¤ë
1107 ¤è¤¦¤Ë¤Ê¤ë¡£
1108 .\"O The caller specifies the target of signals via
1109 .\"O .IR arg ,
1110 .\"O which is a pointer to a
1111 .\"O .IR f_owner_ex
1112 .\"O structure.
1113 .\"O The
1114 .\"O .I type
1115 .\"O field has one of the following values, which define how
1116 .\"O .I pid
1117 .\"O is interpreted:
1118 ¸Æ¤Ó½Ð¤·¸µ¤Ï¡¢
1119 .I arg
1120 ·Ðͳ¤Ç¥·¥°¥Ê¥ë¤ÎÇÛÁ÷Àè¤ò»ØÄꤹ¤ë¡£
1121 .I arg
1122 ¤Ï
1123 .I f_owner_ex
1124 ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤Ç¤¢¤ë¡£
1125 .I type
1126 ¥Õ¥£¡¼¥ë¥É¤Ï°Ê²¼¤Î¤¤¤º¤ì¤«¤ÎÃͤò¼è¤ê¡¢
1127 ¤³¤ÎÃͤˤè¤ê
1128 .I pid
1129 ¤¬¤É¤Î¤è¤¦¤Ë²ò¼á¤µ¤ì¤ë¤«¤¬µ¬Äꤵ¤ì¤ë¡£
1130 .RS
1131 .TP
1132 .BR F_OWNER_TID
1133 .\"O Send the signal to the thread whose thread ID
1134 .\"O (the value returned by a call to
1135 .\"O .BR clone (2)
1136 .\"O or
1137 .\"O .BR gettid (2))
1138 .\"O is specified in
1139 .\"O .IR pid .
1140 ¥¹¥ì¥Ã¥É ID ¤¬
1141 .I pid
1142 ¤Ç»ØÄꤵ¤ì¤¿ÃͤΥ¹¥ì¥Ã¥É¤Ë¤½¤Î¥·¥°¥Ê¥ë¤òÁ÷¤ë
1143 (¥¹¥ì¥Ã¥É ID ¤Ï
1144 .BR clone (2)
1145 ¤ä
1146 .BR gettid (2)
1147 ¤Î¸Æ¤Ó½Ð¤·¤ÇÊÖ¤µ¤ì¤ëÃͤǤ¢¤ë)¡£
1148 .TP
1149 .BR F_OWNER_PID
1150 .\"O Send the signal to the process whose ID
1151 .\"O is specified in
1152 .\"O .IR pid .
1153 ID ¤¬
1154 .I pid
1155 ¤Ç»ØÄꤵ¤ì¤¿ÃÍ¤Î¥×¥í¥»¥¹¤Ë¤½¤Î¥·¥°¥Ê¥ë¤òÁ÷¤ë¡£
1156 .TP
1157 .BR F_OWNER_PGRP
1158 .\"O Send the signal to the process group whose ID
1159 .\"O is specified in
1160 .\"O .IR pid .
1161 .\"O (Note that, unlike with
1162 .\"O .BR F_SETOWN ,
1163 .\"O a process group ID is specified as a positive value here.)
1164 ID ¤¬
1165 .I pid
1166 ¤Ç»ØÄꤵ¤ì¤¿ÃÍ¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ë¤½¤Î¥·¥°¥Ê¥ë¤òÁ÷¤ë¡£
1167 .RB ( F_SETOWN
1168 ¤È°Û¤Ê¤ê¡¢¥×¥í¥»¥¹¥°¥ë¡¼¥× ID ¤Ë¤ÏÀµ¤ÎÃͤò»ØÄꤹ¤ëÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£)
1169 .RE
1170 .TP
1171 .BR F_GETSIG " (\fIvoid\fP)"
1172 .\"O Return (as the function result)
1173 .\"O the signal sent when input or output becomes possible.
1174 .\"O A value of zero means
1175 .\"O .B SIGIO
1176 .\"O is sent.
1177 .\"O Any other value (including
1178 .\"O .BR SIGIO )
1179 .\"O is the
1180 .\"O signal sent instead, and in this case additional info is available to
1181 .\"O the signal handler if installed with
1182 .\"O .BR SA_SIGINFO .
1183 .\"O .I arg
1184 .\"O is ignored.
1185 ÆþÎϤä½ÐÎϤ¬²Äǽ¤Ë¤Ê¤Ã¤¿¾ì¹ç¤ËÁ÷¤ë¥·¥°¥Ê¥ë¤ò
1186 (´Ø¿ô¤Î·ë²Ì¤È¤·¤Æ) ÊÖ¤¹¡£
1187 ÃÍ¥¼¥í¤Ï
1188 .B SIGIO
1189 ¤òÁ÷¤ë¤³¤È¤ò°ÕÌ£¤¹¤ë¡£
1190 .RB ( SIGIO
1191 ¤ò´Þ¤à) Â¾¤ÎÃͤϤ¤¤º¤ì¤â¡¢
1192 .B SIGIO
1193 ¤ÎÂå¤ï¤ê¤ËÁ÷¤ë¥·¥°¥Ê¥ëÈÖ¹æ¤òɽ¤¹¡£
1194 ¸å¼Ô¤Î¾ì¹ç¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ò
1195 .B SA_SIGINFO
1196 ¥Õ¥é¥°ÉÕ¤­¤ÇÀßÄꤹ¤ì¤Ð¡¢¥Ï¥ó¥É¥é¤ÇÄɲäξðÊó¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
1197 .I arg
1198 ¤Ï̵»ë¤µ¤ì¤ë¡£
1199 .TP
1200 .BR F_SETSIG " (\fIlong\fP)"
1201 .\"O Set the signal sent when input or output becomes possible
1202 .\"O to the value given in
1203 .\"O .IR arg .
1204 .\"O A value of zero means to send the default
1205 .\"O .B SIGIO
1206 .\"O signal.
1207 .\"O Any other value (including
1208 .\"O .BR SIGIO )
1209 .\"O is the signal to send instead, and in this case additional info
1210 .\"O is available to the signal handler if installed with
1211 .\"O .BR SA_SIGINFO .
1212 ÆþÎϤä½ÐÎϤ¬²Äǽ¤Ë¤Ê¤Ã¤¿¾ì¹ç¤ËÁ÷¤ë¥·¥°¥Ê¥ë¤ò
1213 .I arg
1214 ¤Ë»ØÄꤵ¤ì¤¿ÃͤËÀßÄꤹ¤ë¡£
1215 ÃÍ¥¼¥í¤Ï
1216 .B SIGIO
1217 ¤òÁ÷¤ë¤³¤È¤ò°ÕÌ£¤¹¤ë¡£
1218 .RB ( SIGIO
1219 ¤ò´Þ¤à) Â¾¤ÎÃͤϤ¤¤º¤ì¤â¡¢
1220 .B SIGIO
1221 ¤ÎÂå¤ï¤ê¤ËÁ÷¤ë¥·¥°¥Ê¥ëÈÖ¹æ¤òɽ¤¹¡£
1222 ¸å¼Ô¤Î¾ì¹ç¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ò
1223 .B SA_SIGINFO
1224 ¥Õ¥é¥°ÉÕ¤­¤ÇÀßÄꤹ¤ì¤Ð¡¢
1225 ¥Ï¥ó¥É¥é¤ÇÄɲäξðÊó¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
1226 .\"
1227 .\" The following was true only up until 2.6.11:
1228 .\"
1229 .\"O .\" Additionally, passing a nonzero value to
1230 .\"O .\" .B F_SETSIG
1231 .\"O .\" changes the signal recipient from a whole process to a specific thread
1232 .\"O .\" within a process.
1233 .\"O .\" See the description of
1234 .\"O .\" .B F_SETOWN
1235 .\"O .\" for more details.
1236 .\" ¤Þ¤¿¡¢
1237 .\" .B F_SETSIG
1238 .\" ¤Ë 0 °Ê³°¤ÎÃͤòÅϤ¹¤È¡¢¥·¥°¥Ê¥ë¤Î¼õ¿®¼Ô¤ò¥×¥í¥»¥¹Á´ÂΤ«¤é
1239 .\" ¥×¥í¥»¥¹Æâ¤ÎÆÃÄê¤Î¥¹¥ì¥Ã¥É¤ËÊѹ¹¤µ¤ì¤ë¡£¾ÜºÙ¤Ï
1240 .\" .B F_SETOWN
1241 .\" ¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£
1242
1243 .\"O By using
1244 .\"O .B F_SETSIG
1245 .\"O with a nonzero value, and setting
1246 .\"O .B SA_SIGINFO
1247 .\"O for the
1248 .\"O signal handler (see
1249 .\"O .BR sigaction (2)),
1250 .\"O extra information about I/O events is passed to
1251 .\"O the handler in a
1252 .\"O .I siginfo_t
1253 .\"O structure.
1254 .B F_SETSIG
1255 ¤Ë¥¼¥í°Ê³°¤ÎÃͤòÀßÄꤷ¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ë
1256 .B SA_SIGINFO
1257 ¥Õ¥é¥°¤òÀßÄꤹ¤ë¤È¡¢
1258 .RB ( sigaction (2)
1259 ¤ò»²¾È) I/O ¥¤¥Ù¥ó¥È¤Ë´Ø¤¹¤ëÄɲäξðÊó¤¬
1260 .I siginfo_t
1261 ¹½Â¤ÂΤǥ·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤ØÅϤµ¤ì¤ë¡£
1262 .\"O If the
1263 .\"O .I si_code
1264 .\"O field indicates the source is
1265 .\"O .BR SI_SIGIO ,
1266 .\"O the
1267 .\"O .I si_fd
1268 .\"O field gives the file descriptor associated with the event.
1269 .\"O Otherwise,
1270 .\"O there is no indication which file descriptors are pending, and you
1271 .\"O should use the usual mechanisms
1272 .\"O .RB ( select (2),
1273 .\"O .BR poll (2),
1274 .\"O .BR read (2)
1275 .\"O with
1276 .\"O .B O_NONBLOCK
1277 .\"O set etc.) to determine which file descriptors are available for I/O.
1278 .I si_code
1279 ¥Õ¥£¡¼¥ë¥É¤¬¼¨¤¹¥·¥°¥Ê¥ë¤Î¸¶°ø¤¬
1280 .B SI_SIGIO
1281 ¤Ç¤¢¤ë¾ì¹ç¡¢
1282 .I si_fd
1283 ¥Õ¥£¡¼¥ë¥É¤Ë¤Ï¥¤¥Ù¥ó¥È¤ËÂбþ¤¹¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬Æþ¤Ã¤Æ¤¤¤ë¡£
1284 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢¤É¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬ÍøÍѲÄǽ¤«¤ò¼¨¤¹¾ðÊó¤Ï
1285 ¤Ê¤¤¤Î¤Ç¡¢¤É¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç I/O ¤¬²Äǽ¤«¤òȽÃǤ¹¤ë¤¿¤á¤Ë¤Ï
1286 Ä̾ï¤Îµ¡¹½
1287 .RB ( select (2),
1288 .BR poll (2),
1289 .B O_NONBLOCK
1290 ¤òÀßÄꤷ¤¿
1291 .BR read (2)
1292 ¤Ê¤É) ¤ò»ÈÍѤ·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1293
1294 .\"O By selecting a real time signal (value >=
1295 .\"O .BR SIGRTMIN ),
1296 .\"O multiple I/O events may be queued using the same signal numbers.
1297 .\"O (Queuing is dependent on available memory).
1298 .\"O Extra information is available
1299 .\"O if
1300 .\"O .B SA_SIGINFO
1301 .\"O is set for the signal handler, as above.
1302 ¥ê¥¢¥ë¥¿¥¤¥à¥·¥°¥Ê¥ë (Ãͤ¬
1303 .B SIGRTMIN
1304 °Ê¾å) ¤òÁªÂò¤·¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢
1305 Ʊ¤¸¥·¥°¥Ê¥ëÈÖ¹æ¤ò»ý¤ÄÊ£¿ô¤Î I/O ¥¤¥Ù¥ó¥È¤¬¥­¥å¡¼¤ËÆþ¤ë¤³¤È¤¬¤¢¤ë
1306 (¥­¥å¡¼¤ËÆþ¤ì¤ë¤«¤É¤¦¤«¤ÏÍøÍѲÄǽ¤Ê¥á¥â¥ê¤Ë°Í¸¤·¤Æ¤¤¤ë)¡£
1307 ¾åµ­¤ÈƱÍÍ¡¢ 
1308 .B SA_SIGINFO
1309 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Î¤¿¤á¤ÎÄɲäξðÊó¤¬ÆÀ¤é¤ì¤ë¡£
1310
1311 .\"O Note that Linux imposes a limit on the
1312 .\"O number of real-time signals that may be queued to a
1313 .\"O process (see
1314 .\"O .BR getrlimit (2)
1315 .\"O and
1316 .\"O .BR signal (7))
1317 .\"O and if this limit is reached, then the kernel reverts to
1318 .\"O delivering
1319 .\"O .BR SIGIO ,
1320 .\"O and this signal is delivered to the entire
1321 .\"O process rather than to a specific thread.
1322 .\" See fs/fcntl.c::send_sigio_to_task() (2.4/2.6) sources -- MTK, Apr 05
1323 °Ê²¼¤ÎÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
1324 Linux ¤Ç¤Ï°ì¤Ä¤Î¥×¥í¥»¥¹¤ËÂФ·¤Æ¥­¥å¡¼¤ËÆþ¤ì¤é¤ì¤ë¥ê¥¢¥ë¥¿¥¤¥à
1325 ¥·¥°¥Ê¥ë¤Î¿ô¤Ë¾å¸Â¤¬Àߤ±¤é¤ì¤Æ¤ª¤ê
1326 .RB ( getrlimit (2)
1327 ¤È
1328 .BR signal (7)
1329 ¤ò»²¾È)¡¢¤³¤Î¾å¸Â¤Ë㤹¤ë¤È¥«¡¼¥Í¥ë¤Ï
1330 .B SIGIO
1331 ¥·¥°¥Ê¥ë¤òÇÛÁ÷¤¹¤ë¡£¤³¤Î
1332 .B SIGIO
1333 ¥·¥°¥Ê¥ë¤Ï¡¢»ØÄꤵ¤ì¤¿¥¹¥ì¥Ã¥É¤Ç¤Ï¤Ê¤¯¥×¥í¥»¥¹Á´ÂΤËÁ÷¤é¤ì¤ë¡£
1334 .PP
1335 .\"O Using these mechanisms, a program can implement fully asynchronous I/O
1336 .\"O without using
1337 .\"O .BR select (2)
1338 .\"O or
1339 .\"O .BR poll (2)
1340 .\"O most of the time.
1341 ¤³¤ì¤é¤Îµ¡¹½¤ò»ÈÍѤ¹¤ë¤³¤È¤Ç¡¢¤Û¤È¤ó¤É¤Î¾ì¹ç¤Ç
1342 .BR select (2)
1343 ¤ä
1344 .BR poll (2)
1345 ¤ò»ÈÍѤ»¤º¤Ë´°Á´¤ÊÈóƱ´ü I/O ¤ò¼ÂÁõ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
1346 .PP
1347 .\"O The use of
1348 .\"O .BR O_ASYNC ,
1349 .\"O .BR F_GETOWN ,
1350 .\"O .B F_SETOWN
1351 .\"O is specific to BSD and Linux.
1352 .BR O_ASYNC ,
1353 .BR F_GETOWN ,
1354 .B F_SETOWN
1355 ¤Î»ÈÍѤϠBSD ¤È Linux ¤ËÆÃÍ­¤Ç¤¢¤ë¡£
1356 .\"O .BR F_GETOWN_EX ,
1357 .\"O .BR F_SETOWN_EX ,
1358 .\"O .BR F_GETSIG ,
1359 .\"O and
1360 .\"O .B F_SETSIG
1361 .\"O are Linux-specific.
1362 .\"O POSIX has asynchronous I/O and the
1363 .\"O .I aio_sigevent
1364 .\"O structure to achieve similar things; these are also available
1365 .\"O in Linux as part of the GNU C Library (Glibc).
1366 .BR F_GETOWN_EX ,
1367 .BR F_SETOWN_EX ,
1368 .BR F_GETSIG ,
1369 .B F_SETSIG
1370 ¤Ï Linux ¸ÇÍ­¤Ç¤¢¤ë¡£POSIX ¤Ë¤Ï¡¢Æ±ÍͤΤ³¤È¤ò¹Ô¤¦¤¿¤á¤Ë¡¢ÈóƱ´ü I/O ¤È
1371 .I aio_sigevent
1372 ¹½Â¤ÂΤ¬¤¢¤ë¡£Linux ¤Ç¤Ï¡¢GNU C ¥é¥¤¥Ö¥é¥ê (Glibc) ¤Î°ìÉô¤È¤·¤Æ
1373 ¤³¤ì¤é¤âÍøÍѲÄǽ¤Ç¤¢¤ë¡£
1374 .\"O .SS Leases
1375 .SS "¥ê¡¼¥¹ (leases)"
1376 .\"O .B F_SETLEASE
1377 .\"O and
1378 .\"O .B F_GETLEASE
1379 .\"O (Linux 2.4 onwards) are used (respectively) to establish a new lease,
1380 .\"O and retrieve the current lease, on the open file description
1381 .\"O referred to by the file descriptor
1382 .\"O .IR fd .
1383 (Linix 2.4 °Ê¹ß¤ÇÍøÍѲÄǽ)
1384 .B F_SETLEASE
1385 ¤Ï¡¢
1386 .I fd
1387 ¤¬»²¾È¤¹¤ë¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ëµ­½Ò¤ËÂФ·¤Æ¿·¤·¤¤¥ê¡¼¥¹¤òÀßÄꤹ¤ë¤Î¤Ë»ÈÍѤµ¤ì¤ë¡£
1388 .B F_GETLEASE
1389 ¤Ï¡¢
1390 .I fd
1391 ¤¬»²¾È¤¹¤ë¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ëµ­½Ò¤ËÂФ·¤ÆÀßÄꤵ¤ì¤Æ¤¤¤ë
1392 ¸½ºß¤Î¥ê¡¼¥¹¤ò¼èÆÀ¤¹¤ë¤Î¤Ë»ÈÍѤµ¤ì¤ë¡£
1393 .\"O A file lease provides a mechanism whereby the process holding
1394 .\"O the lease (the "lease holder") is notified (via delivery of a signal)
1395 .\"O when a process (the "lease breaker") tries to
1396 .\"O .BR open (2)
1397 .\"O or
1398 .\"O .BR truncate (2)
1399 .\"O the file referred to by that file descriptor.
1400 ¥Õ¥¡¥¤¥ë¤Î¥ê¡¼¥¹¤Ë¤è¤ê¡¢
1401 ¤¢¤ë¥×¥í¥»¥¹ ("lease breaker") ¤¬¤½¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬»²¾È
1402 ¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ
1403 .BR open (2)
1404 ¤ä
1405 .BR truncate (2)
1406 ¤ò¹Ô¤ª¤¦¤È¤·¤¿ºÝ¤Ë¡¢¥ê¡¼¥¹¤òÊÝ»ý¤·¤Æ¤¤¤ë¥×¥í¥»¥¹ ("lease holder") ¤Ø
1407 (¥·¥°¥Ê¥ë¤ÎÇÛÁ÷¤Ë¤è¤ë) ÄÌÃΤ¬¹Ô¤ï¤ì¤ë¤È¤¤¤¦µ¡¹½¤¬Ä󶡤µ¤ì¤ë¡£
1408 .TP
1409 .BR F_SETLEASE " (\fIlong\fP)"
1410 .\"O Set or remove a file lease according to which of the following
1411 .\"O values is specified in the integer
1412 .\"O .IR arg :
1413 .I arg
1414 ¤ÎÆâÍƤ˴𤤤ƥե¡¥¤¥ë¤Î¥ê¡¼¥¹¤ÎÀßÄê¡¢ºï½ü¤ò¹Ô¤¦¡£À°¿ô
1415 .I arg
1416 ¤Ë¤Ï°Ê²¼¤ÎÃͤ¬»ØÄê¤Ç¤­¤ë:
1417
1418 .RS
1419 .TP
1420 .B F_RDLCK
1421 .\"O Take out a read lease.
1422 .\"O This will cause the calling process to be notified when
1423 .\"O the file is opened for writing or is truncated.
1424 .\"O .\" The following became true in kernel 2.6.10:
1425 .\"O .\" See the man-pages-2.09 Changelog for further info.
1426 .\"O A read lease can only be placed on a file descriptor that
1427 .\"O is opened read-only.
1428 Æɤ߽Ф·¥ê¡¼¥¹¤ò¼èÆÀ¤¹¤ë¡£¤³¤ì¤Ë¤è¤ê¡¢
1429 ¤½¤Î¥Õ¥¡¥¤¥ë¤¬½ñ¤­¹þ¤ßÍѤ˥ª¡¼¥×¥ó¤µ¤ì¤¿¤ê¡¢¥Õ¥¡¥¤¥ë¤¬ÀÚ¤êµÍ¤á¤é¤ì¤¿¾ì¹ç¤Ë¡¢
1430 ¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ËÄÌÃΤ¬¹Ô¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤ë¡£
1431 .\" °Ê²¼¤ÎÆâÍƤϥ«¡¼¥Í¥ë 2.6.10 ¤Ç¼ÂÁõ¤µ¤ì¤¿¡£
1432 .\" ¤è¤ê¾Ü¤·¤¤¾ðÊó¤Ï man-pages-2.09 ¤Î Changelog ¤ò»²¾È¡£
1433 Æɤ߽Ф·¥ê¡¼¥¹¤òÀßÄê¤Ç¤­¤ë¤Î¤Ï¡¢Æɤ߽Ф·ÀìÍѤǥª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë
1434 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ·¤Æ¤Î¤ß¤Ç¤¢¤ë¡£
1435 .TP
1436 .B F_WRLCK
1437 .\"O Take out a write lease.
1438 .\"O This will cause the caller to be notified when
1439 .\"O the file is opened for reading or writing or is truncated.
1440 .\"O A write lease may be placed on a file only if there are no
1441 .\"O other open file descriptors for the file.
1442 ½ñ¤­¹þ¤ß¥ê¡¼¥¹¤ò¼èÆÀ¤¹¤ë¡£¤³¤ì¤Ë¤è¤ê¡¢
1443 (Æɤ߽Ф·ÍѤ«½ñ¤­¹þ¤ßÍѤˤ«¤«¤ï¤é¤º) ¤½¤Î¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤¿¤ê¡¢
1444 ¥Õ¥¡¥¤¥ë¤¬ÀÚ¤êµÍ¤á¤é¤ì¤¿¾ì¹ç¤Ë¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ËÄÌÃΤ¬¹Ô¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤ë¡£
1445 ½ñ¤­¹þ¤ß¥ê¡¼¥¹¤Ï¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬
1446 ¾¤Ë¤Ê¤¤¾ì¹ç¤Ë¤Î¤ßÀßÄê¤Ç¤­¤ë¡£
1447 .TP
1448 .B F_UNLCK
1449 .\"O Remove our lease from the file.
1450 ¤½¤Î¥Õ¥¡¥¤¥ë¤«¤é¥ê¡¼¥¹¤òºï½ü¤¹¤ë¡£
1451 .RE
1452 .P
1453 .\"O Leases are associated with an open file description (see
1454 .\"O .BR open (2)).
1455 .\"O This means that duplicate file descriptors (created by, for example,
1456 .\"O .BR fork (2)
1457 .\"O or
1458 .\"O .BR dup (2))
1459 .\"O refer to the same lease, and this lease may be modified
1460 .\"O or released using any of these descriptors.
1461 .\"O Furthermore, the lease is released by either an explicit
1462 .\"O .B F_UNLCK
1463 .\"O operation on any of these duplicate descriptors, or when all
1464 .\"O such descriptors have been closed.
1465 ¥ê¡¼¥¹¤Ï¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ëµ­½Ò¤ËÂФ·¤Æ´ØÏ¢ÉÕ¤±¤é¤ì¤ë
1466 .RB ( open (2)
1467 »²¾È)¡£
1468 ¤Ä¤Þ¤ê¡¢
1469 .RB ( fork (2)
1470 ¤ä
1471 .BR dup (2)
1472 ¤Ê¤É¤Ë¤è¤êºîÀ®¤µ¤ì¤¿) ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÎÊ£À½¤ÏƱ¤¸¥ê¡¼¥¹¤ò»²¾È¤·¡¢
1473 Ê£À½¤â´Þ¤á¤¿¤É¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò»È¤Ã¤Æ¤â¤³¤Î¥ê¡¼¥¹¤òÊѹ¹¤·¤¿¤ê
1474 ²òÊü¤·¤¿¤ê¤Ç¤­¤ë¡£
1475 ¤Þ¤¿¡¢¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¤¤¤º¤ì¤«¤ËÂФ·¤Æ
1476 .B F_UNLCK
1477 Áàºî¤¬ÌÀ¼¨Åª¤Ë¼Â¹Ô¤µ¤ì¤¿¾ì¹ç¤ä¡¢¤¹¤Ù¤Æ¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬
1478 ÊĤ¸¤é¤ì¤¿¾ì¹ç¤Ë¤â¡¢¥ê¡¼¥¹¤Ï²òÊü¤µ¤ì¤ë¡£
1479 .P
1480 .\"O Leases may only be taken out on regular files.
1481 .\"O An unprivileged process may only take out a lease on a file whose
1482 .\"O UID (owner) matches the file system UID of the process.
1483 .\"O A process with the
1484 .\"O .B CAP_LEASE
1485 .\"O capability may take out leases on arbitrary files.
1486 ¥ê¡¼¥¹¤Î¼èÆÀ¤ÏÄ̾ï¤Î¥Õ¥¡¥¤¥ë (regular file) ¤ËÂФ·¤Æ¤Î¤ß²Äǽ¤Ç¤¢¤ë¡£
1487 ÈóÆø¢¥×¥í¥»¥¹¤¬¥ê¡¼¥¹¤ò¼èÆÀ¤Ç¤­¤ë¤Î¤Ï¡¢UID (½êÍ­¼Ô) ¤¬¥×¥í¥»¥¹¤Î
1488 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à UID ¤È°ìÃפ¹¤ë¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ¤À¤±¤Ç¤¢¤ë¡£
1489 .B CAP_LEASE
1490 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤Ä¥×¥í¥»¥¹¤ÏǤ°Õ¤Î¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ¥ê¡¼¥¹¤ò¼èÆÀ¤Ç¤­¤ë¡£
1491 .TP
1492 .BR F_GETLEASE " (\fIvoid\fP)"
1493 .\"O Indicates what type of lease is associated with the file descriptor
1494 .\"O .I fd
1495 .\"O by returning either
1496 .\"O .BR F_RDLCK ", " F_WRLCK ", or " F_UNLCK ,
1497 .\"O indicating, respectively, a read lease , a write lease, or no lease.
1498 .\"O .I arg
1499 .\"O is ignored.
1500 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
1501 .I fd
1502 ¤ËÂФ·¤ÆÀßÄꤵ¤ì¤Æ¤¤¤ë¥ê¡¼¥¹¤Î¼ïÊ̤ò¼èÆÀ¤¹¤ë¡£
1503 .BR F_RDLCK ", " F_WRLCK ", " F_UNLCK
1504 ¤Î¤¤¤º¤ì¤«¤¬ÊÖ¤µ¤ì¤ë¡£
1505 .BR F_RDLCK ", " F_WRLCK
1506 ¤Ï¤½¤ì¤¾¤ì¡¢Æɤ߽Ф·¥ê¡¼¥¹¡¢½ñ¤­¹þ¤ß¥ê¡¼¥¹¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤³¤È¤ò¼¨¤·¡¢
1507 .B F_UNLCK
1508 ¤Ï¥ê¡¼¥¹¤¬²¿¤âÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¤³¤È¤ò¼¨¤¹¡£
1509 .I arg
1510 ¤Ï̵»ë¤µ¤ì¤ë¡£
1511 .PP
1512 .\"O When a process (the "lease breaker") performs an
1513 .\"O .BR open (2)
1514 .\"O or
1515 .\"O .BR truncate (2)
1516 .\"O that conflicts with a lease established via
1517 .\"O .BR F_SETLEASE ,
1518 .\"O the system call is blocked by the kernel and
1519 .\"O the kernel notifies the lease holder by sending it a signal
1520 .\"O .RB ( SIGIO
1521 .\"O by default).
1522 ¤¢¤ë¥×¥í¥»¥¹ ("lease folder") ¤¬
1523 .B F_SETLEASE
1524 ¤ÇÀßÄꤵ¤ì¤¿¥ê¡¼¥¹¤ÈÌ·½â¤¹¤ë¤è¤¦¤Ê
1525 .BR open (2)
1526 ¤ä
1527 .BR truncate (2)
1528 ¤ò¼Â¹Ô¤·¤¿¾ì¹ç¡¢
1529 ¤½¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¥«¡¼¥Í¥ë¤Ë¤è¤Ã¤ÆÄä»ß¤µ¤ì¡¢
1530 ¥«¡¼¥Í¥ë¤Ï lease holder ¤Ë¥·¥°¥Ê¥ë (¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï
1531 .BR SIGIO )
1532 ¤òÁ÷¤Ã¤ÆÄÌÃΤò¹Ô¤¦¡£
1533 .\"O The lease holder should respond to receipt of this signal by doing
1534 .\"O whatever cleanup is required in preparation for the file to be
1535 .\"O accessed by another process (e.g., flushing cached buffers) and
1536 .\"O then either remove or downgrade its lease.
1537 lease holder ¤Ï¤³¤Î¥·¥°¥Ê¥ë¤ò¼õ¿®¤·¤¿¤È¤­¤Ë¤Ï¤­¤Á¤ó¤ÈÂбþ¤¹¤Ù¤­¤Ç¤¢¤ë¡£
1538 ¶ñÂÎŪ¤Ë¤Ï¡¢ÊÌ¤Î¥×¥í¥»¥¹¤¬¤½¤Î¥Õ¥¡¥¤¥ë¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤¿¤á¤Î½àÈ÷¤È¤·¤Æ
1539 ɬÍפʸåÊÒÉÕ¤± (Î㤨¤Ð¡¢¥­¥ã¥Ã¥·¥å¤µ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤Î¥Õ¥é¥Ã¥·¥å) ¤ò
1540 ¤¹¤Ù¤Æ¹Ô¤Ã¤Æ¤«¤é¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤Î¥ê¡¼¥¹¤Îºï½ü¤Þ¤¿¤Ï³Ê²¼¤²¤ò¹Ô¤¦¡£
1541 .\"O A lease is removed by performing an
1542 .\"O .B F_SETLEASE
1543 .\"O command specifying
1544 .\"O .I arg
1545 .\"O as
1546 .\"O .BR F_UNLCK .
1547 ¥ê¡¼¥¹¤òºï½ü¤ò¤¹¤ë¤Ë¤Ï¡¢
1548 .I arg
1549 ¤Ë
1550 .B F_UNLCK
1551 ¤ò»ØÄꤷ¤Æ
1552 .B F_SETLEASE
1553 ¤ò¼Â¹Ô¤¹¤ë¡£
1554 .\"O If the lease holder currently holds a write lease on the file,
1555 .\"O and the lease breaker is opening the file for reading,
1556 .\"O then it is sufficient for the lease holder to downgrade
1557 .\"O the lease to a read lease.
1558 .\"O This is done by performing an
1559 .\"O .B F_SETLEASE
1560 .\"O command specifying
1561 .\"O .I arg
1562 .\"O as
1563 .\"O .BR F_RDLCK .
1564 lease holder ¤¬¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤ß¥ê¡¼¥¹¤òÊÝ»ý¤·¤Æ¤¤¤Æ¡¢
1565 lease breaker ¤¬Æɤ߽Ф·ÍѤˤ½¤Î¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ë¾ì¹ç¡¢
1566 lease holder ¤¬ÊÝ»ý¤·¤Æ¤¤¤ë¥ê¡¼¥¹¤òÆɤ߽Ф·¥ê¡¼¥¹¤Ë³Ê²¼¤²¤¹¤ì¤Ð
1567 ½½Ê¬¤Ç¤¢¤ë¡£¤³¤ì¤ò¤¹¤ë¤Ë¤Ï¡¢
1568 .I arg
1569 ¤Ë
1570 .B F_RDLCK
1571 ¤ò»ØÄꤷ¤Æ
1572 .B F_SETLEASE
1573 ¤ò¼Â¹Ô¤¹¤ë¡£
1574
1575 .\"O If the lease holder fails to downgrade or remove the lease within
1576 .\"O the number of seconds specified in
1577 .\"O .I /proc/sys/fs/lease-break-time
1578 .\"O then the kernel forcibly removes or downgrades the lease holder's lease.
1579 lease holder ¤¬
1580 .I /proc/sys/fs/lease-break-time
1581 ¤Ç»ØÄꤵ¤ì¤¿Éÿô°ÊÆâ¤Ë¥ê¡¼¥¹¤Î³Ê²¼¤²¤«ºï½ü¤ò¹Ô¤¨¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
1582 ¥«¡¼¥Í¥ë¤Ï¶¯À©Åª¤Ë¤½¤Î lease holder ¤Î¥ê¡¼¥¹¤òºï½ü¤â¤·¤¯¤Ï³Ê²¼¤²¤ò¹Ô¤¦¡£
1583
1584 .\"O Once the lease has been voluntarily or forcibly removed or downgraded,
1585 .\"O and assuming the lease breaker has not unblocked its system call,
1586 .\"O the kernel permits the lease breaker's system call to proceed.
1587 °ìÅ٥꡼¥¹¤Îºï½ü¤«³Ê²¼¤²¤¬¼«È¯Åª¤â¤·¤¯¤Ï¶¯À©Åª¤Ë¹Ô¤ï¤ì¤ë¤È¡¢
1588 lease breaker ¤¬¤Þ¤À¥·¥¹¥Æ¥à¥³¡¼¥ë¤òºÆ³«¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢
1589 ¥«¡¼¥Í¥ë¤¬ lease breaker ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î³¹Ô¤òµö²Ä¤¹¤ë¡£
1590
1591 .\"O If the lease breaker's blocked
1592 .\"O .BR open (2)
1593 .\"O or
1594 .\"O .BR truncate (2)
1595 .\"O is interrupted by a signal handler,
1596 .\"O then the system call fails with the error
1597 .\"O .BR EINTR ,
1598 .\"O but the other steps still occur as described above.
1599 lease breaker ¤¬¼Â¹Ô¤·¤¿
1600 .BR open (2)
1601 ¤ä
1602 .BR truncate (2)
1603 ¤¬Ää»ßÃæ¤Ë¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ë¤è¤êÃæÃǤµ¤ì¤¿¾ì¹ç¡¢
1604 ¤½¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
1605 .B EINTR
1606 ¥¨¥é¡¼¤Ç¼ºÇÔ¤¹¤ë¤¬¡¢¾å¤Ç½Ò¤Ù¤¿Â¾¤Î½èÍý¤Ï
1607 ¤½¤Î¤Þ¤Þ¹Ô¤ï¤ì¤ë¡£
1608 .\"O If the lease breaker is killed by a signal while blocked in
1609 .\"O .BR open (2)
1610 .\"O or
1611 .\"O .BR truncate (2),
1612 .\"O then the other steps still occur as described above.
1613 .BR open (2)
1614 ¤ä
1615 .BR truncate (2)
1616 ¤¬Ää»ßÃæ¤Ë lease breaker ¤¬¥·¥°¥Ê¥ë¤Ë¤è¤ê kill ¤µ¤ì¤¿¾ì¹ç¡¢
1617 ¾å¤Ç½Ò¤Ù¤¿Â¾¤Î½èÍý¤Ï¤½¤Î¤Þ¤Þ¹Ô¤ï¤ì¤ë¡£
1618 .\"O If the lease breaker specifies the
1619 .\"O .B O_NONBLOCK
1620 .\"O flag when calling
1621 .\"O .BR open (2),
1622 .\"O then the call immediately fails with the error
1623 .\"O .BR EWOULDBLOCK ,
1624 .\"O but the other steps still occur as described above.
1625 lease breaker ¤¬
1626 .BR open (2)
1627 ¤ò¸Æ¤ÖºÝ¤Ë
1628 .B O_NONBLOCK
1629 ¥Õ¥é¥°¤ò»ØÄꤷ¤¿¾ì¹ç¡¢¤½¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
1630 .B EWOULDBLOCK
1631 ¥¨¥é¡¼¤Çľ¤Á¤Ë¼ºÇÔ¤¹¤ë¤¬¡¢¾å¤Ç½Ò¤Ù¤¿Â¾¤Î½èÍý¤Ï¤½¤Î¤Þ¤Þ¹Ô¤ï¤ì¤ë¡£
1632
1633 .\"O The default signal used to notify the lease holder is
1634 .\"O .BR SIGIO ,
1635 .\"O but this can be changed using the
1636 .\"O .B F_SETSIG
1637 .\"O command to
1638 .\"O .BR fcntl ().
1639 .\"O If a
1640 .\"O .B F_SETSIG
1641 .\"O command is performed (even one specifying
1642 .\"O .BR SIGIO ),
1643 .\"O and the signal
1644 .\"O handler is established using
1645 .\"O .BR SA_SIGINFO ,
1646 .\"O then the handler will receive a
1647 .\"O .I siginfo_t
1648 .\"O structure as its second argument, and the
1649 .\"O .I si_fd
1650 .\"O field of this argument will hold the descriptor of the leased file
1651 .\"O that has been accessed by another process.
1652 .\"O (This is useful if the caller holds leases against multiple files).
1653 lease holder ¤Ø¤ÎÄÌÃΤ˻Ȥï¤ì¤ë¥Ç¥Õ¥©¥ë¥È¤Î¥·¥°¥Ê¥ë¤Ï
1654 .B SIGIO
1655 ¤À¤¬¡¢
1656 .BR fcntl ()
1657 ¤Î
1658 .B F_SETSIG
1659 ¥³¥Þ¥ó¥É¤ÇÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
1660 .B F_SETSIG
1661 ¥³¥Þ¥ó¥É¤¬¼Â¹Ô¤µ¤ì
1662 .RB ( SIGIO
1663 ¤ò»ØÄꤵ¤ì¤¿¾ì¹ç¤â´Þ¤à)¡¢
1664 .B SA_SIGINFO
1665 ¥Õ¥é¥°ÉÕ¤­¤Ç¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
1666 ¥Ï¥ó¥É¥é¤ÎÂèÆó°ú¤­¿ô¤È¤·¤Æ
1667 .I siginfo_t
1668 ¹½Â¤ÂΤ¬ÅϤµ¤ì¡¢¤³¤Î°ú¤­¿ô¤Î
1669 .I si_fd
1670 ¥Õ¥£¡¼¥ë¥É¤Ë¤ÏÊÌ¤Î¥×¥í¥»¥¹¤¬¥¢¥¯¥»¥¹¤·¤¿¥ê¡¼¥¹ÀßÄêºÑ¤ß¥Õ¥¡¥¤¥ë¤Î
1671 ¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬Æþ¤Ã¤Æ¤¤¤ë
1672 (¤³¤Îµ¡Ç½¤ÏÊ£¿ô¤Î¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ¥ê¡¼¥¹¤òÀßÄꤹ¤ë¾ì¹ç¤ËÍ­ÍѤǤ¢¤ë)¡£
1673 .\"O .SS "File and directory change notification (dnotify)"
1674 .SS "¥Õ¥¡¥¤¥ë¤ä¥Ç¥£¥ì¥¯¥È¥ê¤ÎÊѹ¹¤ÎÄÌÃΠ(dnotify)"
1675 .TP
1676 .BR F_NOTIFY " (\fIlong\fP)"
1677 .\"O (Linux 2.4 onwards)
1678 (Linux 2.4 °Ê¹ß)
1679 .\"O Provide notification when the directory referred to by
1680 .\"O .I fd
1681 .\"O or any of the files that it contains is changed.
1682 .\"O The events to be notified are specified in
1683 .\"O .IR arg ,
1684 .\"O which is a bit mask specified by ORing together zero or more of
1685 .\"O the following bits:
1686 .I fd
1687 ¤Ç»²¾È¤µ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤«¡¢¤½¤ÎÃæ¤Ë¤¢¤ë¥Õ¥¡¥¤¥ë¤ËÊѹ¹¤¬¤¢¤Ã¤¿¾ì¹ç¤Ë
1688 ÄÌÃΤò¹Ô¤¦¡£¤É¤Î¥¤¥Ù¥ó¥È¤òÄÌÃΤ¹¤ë¤«¤Ï
1689 .I arg
1690 ¤Ç»ØÄꤹ¤ë¡£
1691 .I arg
1692 ¤Ï¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ç¡¢°Ê²¼¤Î¥Ó¥Ã¥È¤Î 0¸Ä°Ê¾å¤ÎÏÀÍýϤò¤È¤Ã¤¿¤â¤Î¤ò»ØÄꤹ¤ë¡£
1693 .RS
1694 .sp
1695 .PD 0
1696 .TP 12
1697 .B DN_ACCESS
1698 .\"O A file was accessed (read, pread, readv)
1699 ¥Õ¥¡¥¤¥ë¤Ø¤Î¥¢¥¯¥»¥¹¤¬¤¢¤Ã¤¿ (read, pread, readv)
1700 .TP
1701 .B DN_MODIFY
1702 .\"O A file was modified (write, pwrite, writev, truncate, ftruncate).
1703 ¥Õ¥¡¥¤¥ë¤ÎÆâÍƤ¬Êѹ¹¤µ¤ì¤¿ (write, pwrite, writev, truncate, ftruncate).
1704 .TP
1705 .B DN_CREATE
1706 .\"O A file was created (open, creat, mknod, mkdir, link, symlink, rename).
1707 ¥Õ¥¡¥¤¥ë¤¬ºîÀ®¤µ¤ì¤¿ (open, creat, mknod, mkdir, link, symlink, rename).
1708 .TP
1709 .B DN_DELETE
1710 .\"O A file was unlinked (unlink, rename to another directory, rmdir).
1711 ¥Õ¥¡¥¤¥ë¤¬ºï½ü (unlink) ¤µ¤ì¤¿ (unlink, Ê̤Υǥ£¥ì¥¯¥È¥ê¤Ø¤Î rename, rmdir)
1712 .TP
1713 .B DN_RENAME
1714 .\"O A file was renamed within this directory (rename).
1715 ¥Ç¥£¥ì¥¯¥È¥êÆâ¤Ç¤Î¥Õ¥¡¥¤¥ë̾¤ÎÊѹ¹¤¬¤¢¤Ã¤¿ (rename)
1716 .TP
1717 .B DN_ATTRIB
1718 .\"O The attributes of a file were changed (chown, chmod, utime[s]).
1719 ¥Õ¥¡¥¤¥ë°À­¤¬Êѹ¹¤µ¤ì¤¿ (chown, chmod, utime[s])
1720 .PD
1721 .RE
1722 .IP
1723 .\"O (In order to obtain these definitions, the
1724 .\"O .B _GNU_SOURCE
1725 .\"O feature test macro must be defined.)
1726 (¾åµ­¤ÎÄêµÁ¤òÍøÍѤ¹¤ë¤Ë¤Ï
1727 .B _GNU_SOURCE
1728 µ¡Ç½¸¡ºº¥Þ¥¯¥í¤òÄêµÁ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£)
1729
1730 .\"O Directory notifications are normally "one-shot", and the application
1731 .\"O must reregister to receive further notifications.
1732 ¥Ç¥£¥ì¥¯¥È¥ê¤ÎÊѹ¹ÄÌÃΤÏÄ̾ï¡Ö°ì²ó¸Â¤ê (one-shot)¡×¤Ç¤¢¤ê¡¢
1733 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¦¤Ç¤½¤Î¸å¤µ¤é¤ËÄÌÃΤò¼õ¿®¤·¤¿¤¤¾ì¹ç¤Ï
1734 ºÆÅÐÏ¿¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1735 .\"O Alternatively, if
1736 .\"O .B DN_MULTISHOT
1737 .\"O is included in
1738 .\"O .IR arg ,
1739 .\"O then notification will remain in effect until explicitly removed.
1740 .I arg
1741 ¤Ë
1742 .B DN_MULTISHOT
1743 ¤¬´Þ¤Þ¤ì¤Æ¤¤¤¿¾ì¹ç¤Ë¤Ï¡¢
1744 Êѹ¹ÄÌÃΤÏÌÀ¼¨Åª¤Ë²ò½ü¤µ¤ì¤ë¤Þ¤ÇÍ­¸ú¾õÂÖ¤¬·Ñ³¤¹¤ë¡£
1745
1746 .\"O .\" The following does seem a poor API-design choice...
1747 .\" °Ê²¼¤Ï API ¤ÎÀ߷פ¬¤Þ¤º¤¤¤È»×¤¦¤Î¤À¤¬...
1748 .\"O A series of
1749 .\"O .B F_NOTIFY
1750 .\"O requests is cumulative, with the events in
1751 .\"O .I arg
1752 .\"O being added to the set already monitored.
1753 .B F_NOTIFY
1754 Í×µá¤ÏÀÑ»»¤µ¤ì¤Æ¤¤¤¯¡£¤Ä¤Þ¤ê¡¢
1755 .I arg
1756 ¤Ç»ØÄꤵ¤ì¤¿¥¤¥Ù¥ó¥È¤¬¤¹¤Ç¤Ë¥â¥Ë¥¿¤µ¤ì¤Æ¤¤¤ë
1757 ¥¤¥Ù¥ó¥È½¸¹ç¤Ë²Ã»»¤µ¤ì¤ë·Á¤Ë¤Ê¤ë¡£
1758 .\"O To disable notification of all events, make an
1759 .\"O .B F_NOTIFY
1760 .\"O call specifying
1761 .\"O .I arg
1762 .\"O as 0.
1763 ¤¹¤Ù¤Æ¤Î¥¤¥Ù¥ó¥È¤ÎÄÌÃΤò̵¸ú¤Ë¤¹¤ë¤Ë¤Ï¡¢
1764 .I arg
1765 ¤Ë 0 ¤ò»ØÄꤷ¤Æ
1766 .B F_NOTIFY
1767 ¤ò¸Æ¤Ó½Ð¤¹É¬Íפ¬¤¢¤ë¡£
1768
1769 .\"O Notification occurs via delivery of a signal.
1770 ÄÌÃΤϥ·¥°¥Ê¥ë¤ÎÇÛÁ÷¤Ç¹Ô¤ï¤ì¤ë¡£
1771 .\"O The default signal is
1772 .\"O .BR SIGIO ,
1773 .\"O but this can be changed using the
1774 .\"O .B F_SETSIG
1775 .\"O command to
1776 .\"O .BR fcntl ().
1777 ¥Ç¥Õ¥©¥ë¥È¤Î¥·¥°¥Ê¥ë¤Ï
1778 .B SIGIO
1779 ¤À¤¬¡¢
1780 .BR fcntl ()
1781 ¤Î
1782 .B F_SETSIG
1783 ¥³¥Þ¥ó¥É¤ÇÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
1784 .\"O In the latter case, the signal handler receives a
1785 .\"O .I siginfo_t
1786 .\"O structure as its second argument (if the handler was
1787 .\"O established using
1788 .\"O .BR SA_SIGINFO )
1789 .\"O and the
1790 .\"O .I si_fd
1791 .\"O field of this structure contains the file descriptor which
1792 .\"O generated the notification (useful when establishing notification
1793 .\"O on multiple directories).
1794 ¸å¼Ô¤Î¾ì¹ç¤Ë¤Ï¡¢
1795 .RB ( SA_SIGINFO
1796 ¥Õ¥é¥°ÉÕ¤­¤Ç¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï)
1797 ¥Ï¥ó¥É¥é¤ÎÂèÆó°ú¤­¿ô¤È¤·¤Æ
1798 .I siginfo_t
1799 ¹½Â¤ÂΤ¬ÅϤµ¤ì¡¢¤³¤Î¹½Â¤ÂΤÎ
1800 .I si_fd
1801 ¥Õ¥£¡¼¥ë¥É¤Ë¤ÏÄÌÃΤιԤï¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬Æþ¤Ã¤Æ¤¤¤ë
1802 (¤³¤Îµ¡Ç½¤ÏÊ£¿ô¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ËÂФ·¤ÆÄÌÃΤòÀßÄꤹ¤ë¾ì¹ç¤ËÍ­ÍѤǤ¢¤ë)¡£
1803
1804 .\"O Especially when using
1805 .\"O .BR DN_MULTISHOT ,
1806 .\"O a real time signal should be used for notification,
1807 .\"O so that multiple notifications can be queued.
1808 ÆäË
1809 .B DN_MULTISHOT
1810 ¤ò»È¤¦¾ì¹ç¤Ï¡¢ÄÌÃΤˤϥꥢ¥ë¥¿¥¤¥à¥·¥°¥Ê¥ë¤ò»È¤¦¤Ù¤­¤Ç¤¢¤ë¡£
1811 ¤½¤ì¤Ï¡¢¥ê¥¢¥ë¥¿¥¤¥à¥·¥°¥Ê¥ë¤ò»È¤¦¤³¤È¤Ç¡¢Ê£¿ô¤ÎÄÌÃΤò¥­¥å¡¼¤ËÆþ¤ì¤ë
1812 ¤³¤È¤¬¤Ç¤­¤ë¤«¤é¤Ç¤¢¤ë¡£
1813
1814 .\"O .B NOTE:
1815 .\"O New applications should use the
1816 .\"O .I inotify
1817 .\"O interface (available since kernel 2.6.13),
1818 .\"O which provides a much superior interface for obtaining notifications of
1819 .\"O file system events.
1820 .\"O See
1821 .\"O .BR inotify (7).
1822 .B Ãí°Õ:
1823 ¿·¤·¤¯¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò½ñ¤¯ºÝ¤Ë¤Ï¡¢(¥«¡¼¥Í¥ë 2.6.13 °Ê¹ß¤ÇÍøÍѲÄǽ¤È¤Ê¤Ã¤¿)
1824 .I inotify
1825 ¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ò»ÈÍѤ¹¤Ù¤­¤Ç¤¢¤ë¡£
1826 .I inotify
1827 ¤Ï¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¥¤¥Ù¥ó¥È¤ÎÄÌÃΤò¼èÆÀ¤¹¤ë¤¿¤á¤Î
1828 ¤º¤Ã¤ÈÍ¥¤ì¤¿¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ç¤¢¤ë¡£
1829 .BR inotify (7)
1830 ¤ò»²¾È¡£
1831 .\"O .SH "RETURN VALUE"
1832 .SH ÊÖ¤êÃÍ
1833 .\"O For a successful call, the return value depends on the operation:
1834 À®¸ù¤·¤¿¾ì¹ç¤ÎÊÖ¤êÃͤÏÁàºî¤Î¼ïÎà¤Ë¤è¤ê°ã¤¦:
1835 .TP 0.9i
1836 .B F_DUPFD
1837 .\"O The new descriptor.
1838 ¿·¤·¤¤¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£
1839 .TP
1840 .B F_GETFD
1841 .\"O Value of flags.
1842 ¥Õ¥é¥°¤ÎÃͤòÊÖ¤¹¡£
1843 .TP
1844 .B F_GETFL
1845 .\"O Value of flags.
1846 ¥Õ¥é¥°¤ÎÃͤòÊÖ¤¹¡£
1847 .TP
1848 .B F_GETLEASE
1849 .\"O Type of lease held on file descriptor.
1850 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ·¤ÆÊÝ»ý¤µ¤ì¤Æ¤¤¤ë¥ê¡¼¥¹¤Î¼ïÊ̤òÊÖ¤¹¡£
1851 .TP
1852 .B F_GETOWN
1853 .\"O Value of descriptor owner.
1854 ¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î½êÍ­¼Ô¤òÊÖ¤¹¡£
1855 .TP
1856 .B F_GETSIG
1857 .\"O Value of signal sent when read or write becomes possible, or zero
1858 .\"O for traditional
1859 .\"O .B SIGIO
1860 .\"O behavior.
1861 Æɤ߹þ¤ß¤ä½ñ¤­½Ð¤·¤¬²Äǽ¤Ë¤Ê¤Ã¤¿»þ¤ËÁ÷¤é¤ì¤ë¥·¥°¥Ê¥ë¤ÎÃÍ¡¢¤â¤·¤¯¤Ï
1862 ÅÁÅýŪ¤Ê
1863 .B SIGIO
1864 Æ°ºî¤Î¾ì¹ç¤Ë¤Ï¥¼¥í¤òÊÖ¤¹¡£
1865 .TP
1866 .\"O All other commands
1867 .\"O Zero.
1868 ¾¤ÎÁ´¤Æ¤Î¥³¥Þ¥ó¥É¤Ï 0 ¤òÊÖ¤¹¡£
1869 .PP
1870 .\"O On error, \-1 is returned, and
1871 .\"O .I errno
1872 .\"O is set appropriately.
1873 ¥¨¥é¡¼¤Î»þ¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢
1874 .I errno
1875 ¤ËŬÀÚ¤ÊÃͤ¬ÀßÄꤵ¤ì¤ë¡£
1876 .\"O .SH ERRORS
1877 .SH ¥¨¥é¡¼
1878 .TP
1879 .\"O .BR EACCES " or " EAGAIN
1880 .BR EACCES " ¤« " EAGAIN
1881 .\"O Operation is prohibited by locks held by other processes.
1882 ¾¤Î¥×¥í¥»¥¹¤¬ÊÝ»ý¤·¤Æ¤¤¤ë¥í¥Ã¥¯¤Ë¤è¤Ã¤ÆÁàºî¤¬¶Ø»ß¤µ¤ì¤Æ¤¤¤ë¡£
1883 .TP
1884 .B EAGAIN
1885 .\"O The operation is prohibited because the file has been memory-mapped by
1886 .\"O another process.
1887 ¤½¤Î¥Õ¥¡¥¤¥ë¤Ï¾¤Î¥×¥í¥»¥¹¤Ë¤è¤Ã¤Æ¥á¥â¥ê¡¦¥Þ¥Ã¥×¤µ¤ì¤Æ¤¤¤ë¤¿¤á¡¢
1888 Áàºî¤¬¶Ø»ß¤µ¤ì¤Æ¤¤¤ë¡£
1889 .TP
1890 .B EBADF
1891 .\"O .I fd
1892 .\"O is not an open file descriptor, or the command was
1893 .\"O .B F_SETLK
1894 .\"O or
1895 .\"O .B F_SETLKW
1896 .\"O and the file descriptor open mode doesn't match with the
1897 .\"O type of lock requested.
1898 .I fd
1899 ¤¬¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
1900 ¤¢¤ë¤¤¤Ï¥³¥Þ¥ó¥É¤¬
1901 .B F_SETLK
1902 ¤Þ¤¿¤Ï
1903 .B F_SETLKW
1904 ¤À¤Ã¤¿¤¬¡¢ÂоݤΥե¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¥ª¡¼¥×¥ó¥â¡¼¥É¤¬
1905 ɬÍפȤʤë¥í¥Ã¥¯¤Î·¿¤Ë¥Þ¥Ã¥Á¤·¤Æ¤¤¤Ê¤¤¡£
1906 .TP
1907 .\"O .B EDEADLK
1908 .\"O It was detected that the specified
1909 .\"O .B F_SETLKW
1910 .\"O command would cause a deadlock.
1911 .B EDEADLK
1912 »ØÄꤵ¤ì¤¿
1913 .B F_SETLKW
1914 ¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤·¤¿¾ì¹ç¤Ë¤Ï¥Ç¥Ã¥É¥í¥Ã¥¯¤Ë¤Ê¤ë¤³¤È¤¬¸¡½Ð¤µ¤ì¤¿¡£
1915 .TP
1916 .B EFAULT
1917 .\"O .I lock
1918 .\"O is outside your accessible address space.
1919 .I lock
1920 ¤¬ÍøÍѲÄǽ¤Ê¥¢¥É¥ì¥¹¶õ´Ö¤Î³°Éô¤Ë¤¢¤ë¡£
1921 .TP
1922 .B EINTR
1923 .\"O For
1924 .\"O .BR F_SETLKW ,
1925 .\"O the command was interrupted by a signal; see
1926 .\"O .BR signal (7).
1927 .\"O For
1928 .\"O .BR F_GETLK " and " F_SETLK ,
1929 .\"O the command was interrupted by a signal before the lock was checked or
1930 .\"O acquired.
1931 .\"O Most likely when locking a remote file (e.g., locking over
1932 .\"O NFS), but can sometimes happen locally.
1933 .B F_SETLKW
1934 ¥³¥Þ¥ó¥É¤¬¥·¥°¥Ê¥ë¤Ë¤è¤ê³ä¤ê¹þ¤Þ¤ì¤¿
1935 .RB ( signal (7)
1936 »²¾È)¡£
1937 .BR F_GETLK " ¤È " F_SETLK
1938 ¤Î¾ì¹ç¡¢¥í¥Ã¥¯¤ò³Îǧ¤·¤¿¤ê¼èÆÀ¤·¤¿¤ê¤¹¤ëÁ°¤Ë¥·¥°¥Ê¥ë¤Ë¤è¤Ã¤Æ³ä¤ê¹þ¤Þ¤ì¤¿¡£
1939 ¤³¤ì¤Ï¤¿¤¤¤Æ¤¤¥ê¥â¡¼¥È¤Î¥Õ¥¡¥¤¥ë¤ò¥í¥Ã¥¯¤¹¤ë¾ì¹ç
1940 (Î㤨¤Ð NFS ¾å¤Ç¥í¥Ã¥¯¤¹¤ë¾ì¹ç) ¤Ëµ¯¤³¤ë¡£
1941 ¤·¤«¤·¥í¡¼¥«¥ë¤Ç¤âµ¯¤³¤ë¾ì¹ç¤¬¤¢¤ë¡£
1942 .TP
1943 .B EINVAL
1944 .\"O For
1945 .\"O .BR F_DUPFD ,
1946 .\"O .I arg
1947 .\"O is negative or is greater than the maximum allowable value.
1948 .\"O For
1949 .\"O .BR F_SETSIG ,
1950 .\"O .I arg
1951 .\"O is not an allowable signal number.
1952 .BR F_DUPFD ¤Ç¡¢
1953 .I arg
1954 ¤¬É餫¡¢¤â¤·¤¯¤Ïµö¤µ¤ì¤ëºÇÂçÃͤè¤ê¤âÂ礭¤¤¡£
1955 .B F_SETSIG
1956 ¤Î¾ì¹ç¡¢
1957 .I arg
1958 ¤¬ÍøÍѲÄǽ¤Ê¥·¥°¥Ê¥ëÈÖ¹æ¤Ç¤Ï¤Ê¤¤¡£
1959 .TP
1960 .B EMFILE
1961 .\"O For
1962 .\"O .BR F_DUPFD ,
1963 .\"O the process already has the maximum number of file descriptors open.
1964 .BR F_DUPFD ¤Ç¡¢
1965 ¥×¥í¥»¥¹¤¬¤¹¤Ç¤ËºÇÂç¿ô¤Þ¤Ç¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ë¡£
1966 .TP
1967 .B ENOLCK
1968 .\"O Too many segment locks open, lock table is full, or a remote locking
1969 .\"O protocol failed (e.g., locking over NFS).
1970 ¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¥í¥Ã¥¯¤Î¿ô¤¬Â¿²á¤®¤Æ¡¢¥í¥Ã¥¯¡¦¥Æ¡¼¥Ö¥ë¤¬¤¤¤Ã¤Ñ¤¤¤Ç¤¢¤ë¡£
1971 ¤Þ¤¿¤Ï remote locking protocol (Î㤨¤Ð NFS ¾å¤Î¥í¥Ã¥¯) ¤¬¼ºÇÔ¤·¤¿¡£
1972 .TP
1973 .B EPERM
1974 .\"O Attempted to clear the
1975 .\"O .B O_APPEND
1976 .\"O flag on a file that has the append-only attribute set.
1977 ÄɲÃÀìÍÑ°À­¤¬ÀßÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î
1978 .B O_APPEND
1979 ¥Õ¥é¥°¤ò¥¯¥ê¥¢¤·¤è¤¦¤È»î¤ß¤¿¡£
1980 .\"O .SH "CONFORMING TO"
1981 .SH ½àµò
1982 .\"O SVr4, 4.3BSD, POSIX.1-2001.
1983 SVr4, 4.3BSD, POSIX.1-2001.
1984 .\"O Only the operations
1985 .\"O .BR F_DUPFD ,
1986 .\"O .BR F_GETFD ,
1987 .\"O .BR F_SETFD ,
1988 .\"O .BR F_GETFL ,
1989 .\"O .BR F_SETFL ,
1990 .\"O .BR F_GETLK ,
1991 .\"O .BR F_SETLK ,
1992 .\"O .BR F_SETLKW ,
1993 .\"O .BR F_GETOWN ,
1994 .\"O and
1995 .\"O .B F_SETOWN
1996 .\"O are specified in POSIX.1-2001.
1997 POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ëÁàºî¤Ï¡¢
1998 .BR F_DUPFD ,
1999 .BR F_GETFD ,
2000 .BR F_SETFD ,
2001 .BR F_GETFL ,
2002 .BR F_SETFL ,
2003 .BR F_GETLK ,
2004 .BR F_SETLK ,
2005 .BR F_SETLKW ,
2006 .BR F_GETOWN ,
2007 .B F_SETOWN
2008 ¤À¤±¤Ç¤¢¤ë¡£
2009
2010 .\"O .B F_DUPFD_CLOEXEC
2011 .\"O is specified in POSIX.1-2008.
2012 .B F_DUPFD_CLOEXEC
2013 ¤Ï POSIX.1-2008 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
2014
2015 .\"O .BR F_GETOWN_EX ,
2016 .\"O .BR F_SETOWN_EX ,
2017 .\"O .BR F_GETSIG ,
2018 .\"O .BR F_SETSIG ,
2019 .\"O .BR F_NOTIFY ,
2020 .\"O .BR F_GETLEASE ,
2021 .\"O and
2022 .\"O .B F_SETLEASE
2023 .\"O are Linux-specific.
2024 .\"O (Define the
2025 .\"O .B _GNU_SOURCE
2026 .\"O macro to obtain these definitions.)
2027 .BR F_GETOWN_EX ,
2028 .BR F_SETOWN_EX ,
2029 .BR F_GETSIG ,
2030 .BR F_SETSIG ,
2031 .BR F_NOTIFY ,
2032 .BR F_GETLEASE ,
2033 .B F_SETLEASE
2034 ¤Ï Linux ¸ÇÍ­¤Ç¤¢¤ë (¤³¤ì¤é¤ÎÄêµÁ¤òÍ­¸ú¤Ë¤¹¤ë¤Ë¤Ï
2035 .B _GNU_SOURCE
2036 ¥Þ¥¯¥í¤òÄêµÁ¤¹¤ë¤³¤È)¡£
2037 .\" .PP
2038 .\"O .\" SVr4 documents additional EIO, ENOLINK and EOVERFLOW error conditions.
2039 .\" SVr4 ¤Ë¤Ï¾¤Ë EFAULT, EINTR, EIO, ENOLINK, EOVERFLOW ¥¨¥é¡¼¾õÂ֤ˤĤ¤¤Æ¤Î
2040 .\" µ­½Ò¤¬¤¢¤ë¡£
2041 .\"O .SH NOTES
2042 .SH Ãí°Õ
2043 .\"O The errors returned by
2044 .\"O .BR dup2 (2)
2045 .\"O are different from those returned by
2046 .\"O .BR F_DUPFD .
2047 ¥¨¥é¡¼¤ÎºÝ¤ÎÊÖ¤êÃͤ¬
2048 .BR dup2 (2)
2049 ¤È
2050 .B F_DUPFD
2051 ¤Ç¤Ï°Û¤Ê¤Ã¤Æ¤¤¤ë¡£
2052
2053 .\"O Since kernel 2.0, there is no interaction between the types of lock
2054 .\"O placed by
2055 .\"O .BR flock (2)
2056 .\"O and
2057 .\"O .BR fcntl ().
2058 ¥«¡¼¥Í¥ë 2.0 °Ê¹ß¤Ç¤Ï¡¢
2059 .BR flock (2)
2060 ¤È
2061 .BR fcntl ()
2062 ¤¬ÀßÄꤹ¤ë¥í¥Ã¥¯¼ïÊ̤δ֤ËÁê¸ßºîÍѤϤʤ¤¡£
2063
2064 .\"O Several systems have more fields in
2065 .\"O .I "struct flock"
2066 .\"O such as, for example,
2067 .\"O .IR l_sysid .
2068 .\"O .\" e.g., Solaris 8 documents this field in fcntl(2), and Irix 6.5
2069 .\"O .\" documents it in fcntl(5).  mtk, May 2007
2070 .\"O Clearly,
2071 .\"O .I l_pid
2072 .\"O alone is not going to be very useful if the process holding the lock
2073 .\"O may live on a different machine.
2074 ¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï¡¢
2075 .I "struct flock"
2076 ¤Ë¾åµ­°Ê³°¤Î¥Õ¥£¡¼¥ë¥É¤¬¤¢¤ë¤â¤Î¤â¤¢¤ë (Î㤨¤Ð
2077 .IR l_sysid )¡£
2078 .\" e.g., Solaris 8 documents this field in fcntl(2), and Irix 6.5
2079 .\" documents it in fcntl(5).  mtk, May 2007
2080 ¤Ï¤Ã¤­¤ê¤È¸À¤¨¤ë¤³¤È¤Ï¡¢¥í¥Ã¥¯¤òÊÝ»ý¤·¤Æ¤¤¤ë¥×¥í¥»¥¹¤¬Ê̤Υޥ·¥ó¤Ë¸ºß
2081 ¤¹¤ë¾ì¹ç¤Ë¤Ï¡¢
2082 .I l_pid
2083 ¤À¤±¤Ï¤¢¤Þ¤êÌò¤Ë¤¿¤¿¤Ê¤¤¤À¤í¤¦¤È¤¤¤¦¤³¤È¤Ç¤¢¤ë¡£
2084 .\"O .SH BUGS
2085 .SH ¥Ð¥°
2086 .\"O A limitation of the Linux system call conventions on some
2087 .\"O architectures (notably i386) means that if a (negative)
2088 .\"O process group ID to be returned by
2089 .\"O .B F_GETOWN
2090 .\"O falls in the range \-1 to \-4095, then the return value is wrongly
2091 .\"O interpreted by glibc as an error in the system call;
2092 .\"O .\" glibc source: sysdeps/unix/sysv/linux/i386/sysdep.h
2093 .\"O that is, the return value of
2094 .\"O .BR fcntl ()
2095 .\"O will be \-1, and
2096 .\"O .I errno
2097 .\"O will contain the (positive) process group ID.
2098 ¤¤¤¯¤Ä¤«¤Î¥¢¡¼¥­¥Æ¥¯¥Á¥ã (Æäˠi386) ¤Ë¤ª¤±¤ë Linux ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î´·½¬
2099 ¤Î¤¿¤á°Ê²¼¤ÎÀ©¸Â¤¬Â¸ºß¤¹¤ë¡£
2100 .B F_GETOWN
2101 ¤¬ÊÖ¤¹ (Éé¤Î) ¥×¥í¥»¥¹¥°¥ë¡¼¥×ID ¤¬ \-1 ¤«¤é \-4095 ¤ÎÈϰϤËÆþ¤Ã¤¿¾ì¹ç¡¢
2102 glibc ¤Ï¤³¤ÎÊÖ¤êÃͤò¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ç¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¤È
2103 ´Ö°ã¤Ã¤Æ²ò¼á¤·¤Æ¤·¤Þ¤¦¡£¤Ä¤Þ¤ê¡¢
2104 .BR fcntl ()
2105 ¤ÎÊÖ¤êÃͤϠ\-1 ¤È¤Ê¤ê¡¢
2106 .I errno
2107 ¤Ë¤Ï (Àµ¤Î) ¥×¥í¥»¥¹¥°¥ë¡¼¥×ID ¤¬ÀßÄꤵ¤ì¤ë¤³¤È¤Ë¤Ê¤ë¡£
2108 .\"O The Linux-specific
2109 .\"O .BR F_SETOWN_EX
2110 .\"O and
2111 .\"O .BR F_GETOWN_EX
2112 .\"O operations avoid this problem.
2113 Linux ¸ÇÍ­¤Î
2114 .B F_SETOWN_EX
2115 ¤È
2116 .B F_GETOWN_EX
2117 ¤Ç¤Ï¤³¤ÎÌäÂê¤ò²óÈò¤Ç¤­¤ë¡£
2118 .\"O .\" mtk, Dec 04: some limited testing on alpha and ia64 seems to
2119 .\"O .\" indicate that ANY negative PGID value will cause F_GETOWN
2120 .\"O .\" to misinterpret the return as an error. Some other architectures
2121 .\"O .\" seem to have the same range check as i386.
2122 .\" mtk, Dec 04: alpha ¤È ia64 ¤Ç¤Ï¡¢¾¯¤·¥Æ¥¹¥È¤·¤Æ¤ß¤¿¸Â¤ê¡¢
2123 .\" ¡Ö¤É¤ó¤Ê¡×Éé¤Î PGID ¤Ç¤â F_GETOWN ¤Ç¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¤È´Ö°ã¤Ã¤Æ
2124 .\" ²ò¼á¤µ¤ì¤Æ¤·¤Þ¤¦¤è¤¦¤À¡£Â¾¤Î¤¤¤¯¤Ä¤«¤Î¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Ç¤Ï¡¢
2125 .\" i386 ¤ÈƱÍͤÎÈϰϤΥÁ¥§¥Ã¥¯¤¬¹Ô¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£
2126
2127 .\"O In Linux 2.4 and earlier, there is bug that can occur
2128 .\"O when an unprivileged process uses
2129 .\"O .B F_SETOWN
2130 .\"O to specify the owner
2131 .\"O of a socket file descriptor
2132 .\"O as a process (group) other than the caller.
2133 .\"O In this case,
2134 .\"O .BR fcntl ()
2135 .\"O can return \-1 with
2136 .\"O .I errno
2137 .\"O set to
2138 .\"O .BR EPERM ,
2139 .\"O even when the owner process (group) is one that the caller
2140 .\"O has permission to send signals to.
2141 .\"O Despite this error return, the file descriptor owner is set,
2142 .\"O and signals will be sent to the owner.
2143 Linux 2.4 °ÊÁ°¤Ç¤Ï¡¢ÈóÆø¢¥×¥í¥»¥¹¤¬
2144 .B F_SETOWN
2145 ¤ò»È¤Ã¤Æ¡¢¥½¥±¥Ã¥È¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î½êÍ­¼Ô¤Ë
2146 ¸Æ¤Ó½Ð¤·¸µ°Ê³°¤Î¥×¥í¥»¥¹ (¤ä¥×¥í¥»¥¹¥°¥ë¡¼¥×) ¤ò»ØÄꤹ¤ë¤È
2147 ȯÀ¸¤¹¤ë¥Ð¥°¤¬¤¢¤ë¡£¤³¤Î¾ì¹ç¡¢
2148 ¸Æ¤Ó½Ð¤·¸µ¤¬½êÍ­¼Ô¤È¤·¤Æ»ØÄꤷ¤¿¥×¥í¥»¥¹ (¤ä¥×¥í¥»¥¹¥°¥ë¡¼¥×) ¤Ë
2149 ¥·¥°¥Ê¥ë¤òÁ÷¤ëµö²Ä¤ò»ý¤Ã¤Æ¤¤¤¿¤È¤·¤Æ¤â¡¢
2150 .BR fcntl ()
2151 ¤¬ \-1 ¤òÊÖ¤·
2152 .I errno
2153 ¤Ë
2154 .B EPERM
2155 ¤òÀßÄꤹ¤ë¤³¤È¤¬¤¢¤ë¡£
2156 ¤³¤Î¥¨¥é¡¼¤¬Ê֤俤ˤ⤫¤«¤ï¤é¤º¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î½êÍ­¼Ô
2157 ¤ÏÀßÄꤵ¤ì¡¢¥·¥°¥Ê¥ë¤Ï¤½¤Î½êÍ­¼Ô¤ËÁ÷¤é¤ì¤ë¡£
2158
2159 .\"O The implementation of mandatory locking in all known versions of Linux
2160 .\"O is subject to race conditions which render it unreliable:
2161 .\"O .\" http://marc.info/?l=linux-kernel&m=119013491707153&w=2
2162 .\"O a
2163 .\"O .BR write (2)
2164 .\"O call that overlaps with a lock may modify data after the mandatory lock is
2165 .\"O acquired;
2166 .\"O a
2167 .\"O .BR read (2)
2168 .\"O call that overlaps with a lock may detect changes to data that were made
2169 .\"O only after a write lock was acquired.
2170 .\"O Similar races exist between mandatory locks and
2171 .\"O .BR mmap (2).
2172 .\"O It is therefore inadvisable to rely on mandatory locking.
2173 ¤³¤ì¤Þ¤Ç¤Î Linux ¤ÎÁ´¤Æ¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤ª¤±¤ë¶¯À©¥í¥Ã¥¯¤Î¼ÂÁõ¤Ï¡¢
2174 ¶¥¹ç¾ò·ï²¼¤Ç¶¯À©¥í¥Ã¥¯¤¬ÉÔ´°Á´¤Ë¤Ê¤ë¤è¤¦¤Ê¾ì¹ç¤¬¤¢¤ë¡£
2175 .\" http://marc.info/?l=linux-kernel&m=119013491707153&w=2
2176 ¥í¥Ã¥¯¤È½Å¤Ê¤Ã¤Æ¼Â¹Ô¤µ¤ì¤¿
2177 .BR write (2)
2178 ¤Î¸Æ¤Ó½Ð¤·¤Ï¶¯À©¥í¥Ã¥¯¤¬³ÍÆÀ¤µ¤ì¤¿¸å¤Ë¤â¥Ç¡¼¥¿¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
2179 ¥í¥Ã¥¯¤È½Å¤Ê¤Ã¤Æ¼Â¹Ô¤µ¤ì¤¿
2180 .BR read (2)
2181 ¤Î¸Æ¤Ó½Ð¤·¤Ï¶¯À©¥í¥Ã¥¯¤¬³ÍÆÀ¤µ¤ì¤¿¸å¤Ë¤Ê¤Ã¤Æ¹Ô¤ï¤ì¤¿¥Ç¡¼¥¿¤ÎÊѹ¹¤ò
2182 ¸¡½Ð¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
2183 ƱÍͤζ¥¹ç¾ò·ï¤¬¶¯À©¥í¥Ã¥¯¤È
2184 .BR mmap (2)
2185 ¤Î´Ö¤Ë¤â¸ºß¤¹¤ë¡£¤½¤ì¤æ¤¨¡¢¶¯À©¥í¥Ã¥¯¤ËÍê¤ë¤Î¤Ï¤ªÁ¦¤á¤Ç¤­¤Ê¤¤¡£
2186 .\"O .SH "SEE ALSO"
2187 .SH ´ØÏ¢¹àÌÜ
2188 .BR dup2 (2),
2189 .BR flock (2),
2190 .BR open (2),
2191 .BR socket (2),
2192 .BR lockf (3),
2193 .BR capabilities (7),
2194 .BR feature_test_macros (7)
2195 .P
2196 .\"O See also
2197 .\"O .IR locks.txt ,
2198 .\"O .IR mandatory-locking.txt ,
2199 .\"O and
2200 .\"O .I dnotify.txt
2201 .\"O in the kernel source directory
2202 .\"O .IR Documentation/filesystems/ .
2203 .\"O (On older kernels, these files are directly under the
2204 .\"O .I Documentation/
2205 .\"O directory, and
2206 .\"O .I mandatory-locking.txt
2207 .\"O is called
2208 .\"O .IR mandatory.txt .)
2209 ¥«¡¼¥Í¥ë¥½¡¼¥¹¤Î
2210 .IR Documentation/filesystems/
2211 ¥Ç¥£¥ì¥¯¥È¥êÆâ¤Î
2212 .IR locks.txt ,
2213 .IR mandatory-locking.txt ,
2214 .I dnotify.txt
2215 ¤â»²¾È¤Î¤³¤È¡£
2216 (°ÊÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¤Ï
2217 .I Documentation/
2218 ¥Ç¥£¥ì¥¯¥È¥êľ²¼¤Ë¤¢¤ê¡¢
2219 .I mandatory-locking.txt
2220 ¤Ï
2221 .I mandatory.txt
2222 ¤È¤¤¤¦Ì¾Á°¤Ç¤¢¤Ã¤¿¡£)