2 .\" Hey Emacs! This file is -*- nroff -*- source.
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.
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.
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.
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
26 .\" Formatted or processed versions of this manual, if unaccompanied by
27 .\" the source, must acknowledge the copyright and authors of this work.
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
59 .\" Japanese Version Copyright (c) 1996 Takeshi Ueno
60 .\" and Copyright (c) 2005, 2006, 2008 Akihiro MOTOKI
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
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 が利用可能になったことを示すシグナル
81 .TH FCNTL 2 2009-10-17 "Linux" "Linux Programmer's Manual"
84 .\"O fcntl \- manipulate file descriptor
85 fcntl \- ファイルディスクリプタの操作を行う
89 .B #include <unistd.h>
92 .BI "int fcntl(int " fd ", int " cmd ", ... /* " arg " */ );"
97 .\"O performs one of the operations described below on the open file descriptor
99 .\"O The operation is determined by
109 .\"O can take an optional third argument.
110 .\"O Whether or not this argument is required is determined by
112 .\"O The required argument type is indicated in parentheses after each
114 .\"O name (in most cases, the required type is
116 .\"O and we identify the argument using the name
120 .\"O is specified if the argument is not required.
122 はオプションとして第三引き数をとることができる。
137 .\"O .SS "Duplicating a file descriptor"
140 .BR F_DUPFD " (\fIlong\fP)"
141 .\"O Find the lowest numbered available file descriptor
142 .\"O greater than or equal to
144 .\"O and make it be a copy of
146 .\"O This is different from
148 .\"O which uses exactly the descriptor specified.
157 では指定されたディスクリプタが使われる点が違う。
159 .\"O On success, the new descriptor is returned.
160 成功すると、新しいディスクリプタが返される。
164 .\"O for further details.
169 .\"O .BR F_DUPFD_CLOEXEC " (\fIlong\fP; since Linux 2.6.24)"
170 .BR F_DUPFD_CLOEXEC " (\fIlong\fP; Linux 2.6.24 以降)"
173 .\"O but additionally set the
174 .\"O close-on-exec flag for the duplicate descriptor.
176 と同様だが、それに加えて複製されたディスクリプタに対して
177 close-on-exec フラグをセットする。
178 .\"O Specifying this flag permits a program to avoid an additional
181 .\"O operation to set the
191 .\"O For an explanation of why this flag is useful,
192 .\"O see the description of
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.
210 .\"O bit is 0, the file descriptor will remain open across an
212 .\"O otherwise it will be closed.
213 以下のコマンドを使って、ファイルディスクリプタに関連するフラグ
215 現在のところ、定義されているフラグは一つだけである:
219 ビットが 0 なら、ファイルディスクリプタは
221 を行ってもオープンされたままだが、そうでない場合はクローズされる。
223 .BR F_GETFD " (\fIvoid\fP)"
224 .\"O Read the file descriptor flags;
227 ファイルディスクリプタ・フラグを読み出す。
231 .BR F_SETFD " (\fIlong\fP)"
232 .\"O Set the file descriptor flags to the value specified by
237 .\"O .SS "File status flags"
239 .\"O Each open file description has certain associated status flags,
243 .\"O .\" .BR creat (2),
244 .\"O and possibly modified by
246 .\"O Duplicated file descriptors
249 .\"O .BR fcntl (F_DUPFD),
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 ファイル記述毎に設定される状態フラグがいくつかある。これらのフラグは
264 などで) 複製されたファイルディスクリプタ同士は
269 .\"O The file status flags and their semantics are described in
275 .BR F_GETFL " (\fIvoid\fP)"
276 .\"O Read the file status flags;
283 .BR F_SETFL " (\fIlong\fP)"
284 .\"O Set the file status flags to the value specified by
286 .\"O File access mode
287 .\"O .RB ( O_RDONLY ", " O_WRONLY ", " O_RDWR )
288 .\"O and file creation flags
290 .\"O .BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", " O_TRUNC )
299 .RB ( O_RDONLY ", " O_WRONLY ", " O_RDWR )
301 .BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", " O_TRUNC )
303 .\"O On Linux this command can only change the
311 Linux では、このコマンドで変更できるのは
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"
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,
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 (レコード・ロックはファイルセグメント・ロックや
339 は、以下に示すフィールドを含む構造体へのポインタである
340 (フィールドの順序は関係なく、構造体に他のフィールドがあってもよい)。
346 short l_type; /* Type of lock: F_RDLCK,
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
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.
365 .IR l_whence ", " l_start ", " l_len
366 フィールドで、ロックを行いたいバイト範囲を指定する。
367 ファイルの末尾より後ろのバイトをロックすることはできるが、
368 ファイルの先頭より前のバイトをロックすることはできない。
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
377 .\"O the current file offset (if
381 .\"O or the end of the file (if
385 .\"O In the final two cases,
387 .\"O can be a negative number provided the
388 .\"O offset does not lie before the start of the file.
390 はロックを行う領域の開始オフセットである。
401 の場合は現在のファイルオフセットからのオフセット、
405 の場合はファイルの末尾からのオフセットと解釈される。
412 .\"O specifies the number of bytes to be locked.
415 .\"O is positive, then the range to be locked covers bytes
417 .\"O up to and including
418 .\"O .IR l_start + l_len \- 1 .
419 .\"O Specifying 0 for
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.
431 .IR l_start + l_len \- 1
434 に 0 を指定した場合は特別な意味を持つ:
435 .IR l_whence " and " l_start
436 で指定される位置からファイルの末尾までの全てのバイトをロックする
437 (ファイルがどんなに大きくなったとしてもファイルの末尾までロックする)。
439 .\"O POSIX.1-2001 allows (but does not require)
440 .\"O an implementation to support a negative
444 .\"O is negative, the interval described by
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.
453 をサポートする実装を認めている (必須ではない)。
460 この動作はカーネル 2.4.21 以降および 2.5.49 以降の Linux で
465 .\"O field can be used to place a read
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.
476 フィールドは、ファイルに対して読み出しロック
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 新規のロックがロックが設定されている領域に対して適用されると、既存のロック
495 (新規のロックで指定されたバイト範囲が既存ロックの範囲と一致する場合以外では、
496 変換の過程で既存のロックの分割、縮小、結合が行われることがある)。
498 .BR F_SETLK " (\fIstruct flock *\fP)"
499 .\"O Acquire a lock (when
505 .\"O or release a lock (when
509 .\"O on the bytes specified by the
510 .\"O .IR l_whence ", " l_start ", and " l_len
523 .IR l_whence ", " l_start ", " l_len
525 .\"O If a conflicting lock is held by another process,
526 .\"O this call returns \-1 and sets
532 指定されたロックが他のプロセスが設定しているロックと衝突する場合は、
541 .BR F_SETLKW " (\fIstruct flock *\fP)"
544 .\"O but if a conflicting lock is held on the file, then wait for that
545 .\"O lock to be released.
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
556 .\"O .BR signal (7)).
557 待っている間にシグナルを受けた場合は、システムコールは中断され、
558 (シグナルハンドラが戻った直後に) 返り値 \-1 を返す (また
566 .BR F_GETLK " (\fIstruct flock *\fP)"
567 .\"O On input to this call,
569 .\"O describes a lock we would like to place on the file.
572 にはそのファイルに適用しようとするロックに関する情報が入っている。
573 .\"O If the lock could be placed,
575 .\"O does not actually place it, but returns
581 .\"O and leaves the other fields of the structure unchanged.
590 を設定し、他のフィールドは変更せずに、復帰する。
591 .\"O If one or more incompatible locks would prevent
592 .\"O this lock being placed, then
594 .\"O returns details about one of these locks in the
595 .\"O .IR l_type ", " l_whence ", " l_start ", and " l_len
600 .\"O to be the PID of the process holding that lock.
601 違う種別のロックが (一つもしくは複数) 適用されていて
604 は、原因となったロックの一つについての詳細情報を構造体
607 .IR l_type ", " l_whence ", " l_start ", " l_len
610 にロックを保持しているプロセスの PID を設定して、復帰する。
612 .\"O In order to place a read lock,
614 .\"O must be open for reading.
615 .\"O In order to place a write lock,
617 .\"O must be open for writing.
618 .\"O To place both types of lock, open a file read-write.
621 は読み出し用にオープンされていなければならない。
624 は書き込み用にオープンされていなければならない。
625 読み書き両方のロックを適用するには、読み書き両用で
628 .\"O As well as being removed by an explicit
630 .\"O record locks are automatically released when the process
631 .\"O terminates or if it closes
633 .\"O file descriptor referring to a file on which locks are held.
637 プロセスが終了したときや、ロックが適用されているファイルを参照している
638 ファイルディスクリプタのいずれかがクローズされた場合にも解放される。
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 .\" の呼び出しによって同じファイルを参照するファイルディスクリプタが
646 .\"O This is bad: it means that a process can lose the locks on
651 .\"O when for some reason a library function decides to open, read
657 といったファイルにロックを適用しているときに、
658 あるライブラリ関数が何かの理由で同じファイルを open, read, close
659 すると、そのファイルへのロックが失われることになる。
661 .\"O Record locks are not inherited by a child created via
663 .\"O but are preserved across an
667 で作成された子プロセスには継承されないが、
671 .\"O Because of the buffering performed by the
673 .\"O library, the use of record locking with routines in that package
674 .\"O should be avoided; use
681 stdio 関連の関数ではレコードのロックの使用は回避される;
687 .\"O .SS "Mandatory locking"
688 .SS "強制ロック (mandatory locking)"
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) の二種類があるが、デフォルトではアドバイザリ・ロックとなる。
695 .\"O Advisory locks are not enforced and are useful only between
696 .\"O cooperating processes.
697 アドバイザリ・ロックに強制力はなく、協調して動作するプロセス間でのみ
700 .\"O Mandatory locks are enforced for all processes.
701 強制ロックは全てのプロセスに対して効果がある。
702 .\"O If a process tries to perform an incompatible access (e.g.,
706 .\"O on a file region that has an incompatible mandatory lock,
707 .\"O then the result depends upon whether the
709 .\"O flag is enabled for its open file description.
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.
717 .\"O flag is enabled, then the system call fails with the error
719 あるプロセスが互換性のない強制ロックが適用されたファイル領域に対して
723 により) 互換性のないアクセスを実行しようとした場合、
729 フラグが有効になっていないときは、ロックが削除されるか、
730 ロックがアクセスと互換性のあるモードに変換されるまで、
731 システムコールは停止 (block) される。
733 フラグが有効になっているときは、システムコールはエラー
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
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
753 強制ロックを使用するためには、ロック対象のファイルが含まれるファイルシステム
754 と、ロック対象のファイル自身の両方について、強制ロックが有効になっていなけれ
755 ばならない。ファイルシステムについて強制ロックを有効にするには、
757 に "\-o mand" オプションを渡すか、
761 フラグを指定する。ファイルについて強制ロックを有効にするには、
762 そのファイルのグループ実行許可 (group execute permission) を無効とし、
763 かつ set-group-ID 許可ビットを有効にする
769 .\"O The Linux implementation of mandatory locking is unreliable.
771 Linux の強制ロックの実装は信頼性に欠けるものである。
773 .\"O .SS "Managing signals"
777 .\"O .BR F_GETOWN_EX ,
778 .\"O .BR F_SETOWN_EX ,
782 .\"O are used to manage I/O availability signals:
789 は、I/O が利用可能になったことを示すシグナルを管理するために使用される。
791 .BR F_GETOWN " (\fIvoid\fP)"
792 .\"O Return (as the function result)
793 .\"O the process ID or process group currently receiving
797 .\"O signals for events on file descriptor
799 .\"O Process IDs are returned as positive values;
800 .\"O process group IDs are returned as negative values (but see BUGS below).
809 を受けているプロセスのプロセスID かプロセスグループを
812 プロセスグループID は負の値として返される (下記のバグの章を参照)。
816 .BR F_SETOWN " (\fIlong\fP)"
817 .\"O Set the process ID or process group ID that will receive
821 .\"O signals for events on file descriptor
823 .\"O to the ID given in
825 .\"O A process ID is specified as a positive value;
826 .\"O a process group ID is specified as a negative value.
834 プロセス ID またはプロセスグループID を
838 プロセスグループID は負の値として指定する。
839 .\"O Most commonly, the calling process specifies itself as the owner
843 .\"O .BR getpid (2)).
844 ほとんどの場合、呼び出し元プロセスは所有者として自分自身を指定する
851 .\"O .\" From glibc.info:
855 .\"O status flag on a file descriptor by using the
861 .\"O signal is sent whenever input or output becomes possible
862 .\"O on that file descriptor.
864 .\"O can be used to obtain delivery of a signal other than
869 コマンドを使用してファイルディスクリプタに
871 状態フラグを設定した場合には、そのファイルディスクリプタへの
878 以外の別のシグナルの配送を受けられるように
880 .\"O If this permission check fails, then the signal is
881 .\"O silently discarded.
882 許可 (permission) のチェックで失敗した場合には、
885 .\"O Sending a signal to the owner process (group) specified by
887 .\"O is subject to the same permissions checks as are described for
889 .\"O where the sending process is the one that employs
891 .\"O (but see BUGS below).
893 により指定された所有者のプロセス (またはプロセスグループ) に
896 に書かれているのと同じ許可のチェックが行われる。
900 (但し、下記の「バグ」の章を参照のこと)。
902 .\"O If the file descriptor
904 .\"O refers to a socket,
907 .\"O the recipient of
909 .\"O signals that are delivered when out-of-band
910 .\"O data arrives on that socket.
912 .\"O is sent in any situation where
914 .\"O would report the socket as having an "exceptional condition".)
915 ファイルディスクリプタがソケットを参照している場合は、
917 を使用して、ソケットに帯域外 (out-of-band) データが届いた時に
919 シグナルを配送する相手を選択することもできる
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
930 .\"O .\" If the file descriptor
932 .\"O .\" refers to a terminal device, then SIGIO
933 .\"O .\" signals are sent to the foreground process group of the terminal.
935 .\" カーネルソースを見るとこの記述は間違っているようだし、
936 .\" プログラムを書いてみたところ、端末のフォアグランド・プロセスグループで
937 .\" なくても、端末が生成した SIGIO シグナルを受けとる。
940 .\" ファイルディスクリプタが端末デバイスを参照している場合には、
941 .\" SIGIO シグナルはその端末のフォアグランド・プロセスグループへと送られる。
943 .\"O The following was true in 2.6.x kernels up to and including
945 バージョン 2.6.11 以前の 2.6.x カーネルでは、以下に示す動作であった。
948 .\"O If a nonzero value is given to
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
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 使って動作しているマルチスレッド・プロセスで
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
975 .\"O to get sensible results when
980 を使う場合には、きちんと結果を受け取るには、
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
993 .\"O in this scenario.)
994 (現状の Linux スレッド実装では、メイン・スレッドのスレッドID は
995 そのスレッドのプロセスID と同じである。つまり、
996 シグナル・スレッドのプログラムではこの場合
1001 .\"O Note, however, that the statements in this paragraph do not apply
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
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 ソケットの帯域外データが届いたときに生成される
1016 このシグナルは常にプロセスかプロセスグループに送られ、
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)
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
1034 .\"O signals at a particular thread.
1035 上記の動作は、Linux 2.6.12 で図らずも削除され、
1037 Linux 2.6.32 以降で、特定のスレッド宛にシグナル
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
1051 .\"O The information is returned in the structure pointed to by
1053 .\"O which has the following form:
1056 操作で定義された現在のファイルディスクリプタの所有者設定
1059 が指す構造体に格納されて返される。構造体は以下の通りである。
1072 .\"O field will have one of the values
1073 .\"O .BR F_OWNER_TID ,
1074 .\"O .BR F_OWNER_PID ,
1076 .\"O .BR F_OWNER_PGRP .
1085 .\"O field is a positive integer representing a thread ID, process ID,
1086 .\"O or process group ID.
1089 .\"O for more details.
1091 フィールドは、スレッド ID、プロセス ID、プロセスグループ ID を
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
1100 .\"O It allows the caller to direct I/O availability signals
1101 .\"O to a specific thread, process, or process group.
1105 この操作を使うと、I/O が利用可能になったことを示すシグナルを、
1106 特定のスレッド、プロセス、プロセスグループに送ることができる
1108 .\"O The caller specifies the target of signals via
1110 .\"O which is a pointer to a
1115 .\"O field has one of the following values, which define how
1117 .\"O is interpreted:
1133 .\"O Send the signal to the thread whose thread ID
1134 .\"O (the value returned by a call to
1137 .\"O .BR gettid (2))
1138 .\"O is specified in
1142 で指定された値のスレッドにそのシグナルを送る
1150 .\"O Send the signal to the process whose ID
1151 .\"O is specified in
1155 で指定された値のプロセスにそのシグナルを送る。
1158 .\"O Send the signal to the process group whose ID
1159 .\"O is specified in
1161 .\"O (Note that, unlike with
1163 .\"O a process group ID is specified as a positive value here.)
1166 で指定された値のプロセスグループにそのシグナルを送る。
1168 と異なり、プロセスグループ ID には正の値を指定する点に注意すること。)
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
1177 .\"O Any other value (including
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 .
1185 入力や出力が可能になった場合に送るシグナルを
1196 フラグ付きで設定すれば、ハンドラで追加の情報を得ることができる。
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
1204 .\"O A value of zero means to send the default
1207 .\"O Any other value (including
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 入力や出力が可能になった場合に送るシグナルを
1225 ハンドラで追加の情報を得ることができる。
1227 .\" The following was true only up until 2.6.11:
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.
1238 .\" に 0 以外の値を渡すと、シグナルの受信者をプロセス全体から
1239 .\" プロセス内の特定のスレッドに変更される。詳細は
1245 .\"O with a nonzero value, and setting
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
1255 にゼロ以外の値を設定し、シグナルハンドラに
1259 を参照) I/O イベントに関する追加の情報が
1264 .\"O field indicates the source is
1268 .\"O field gives the file descriptor associated with the event.
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),
1277 .\"O set etc.) to determine which file descriptors are available for I/O.
1283 フィールドにはイベントに対応するファイルディスクリプタが入っている。
1284 それ以外の場合は、どのファイルディスクリプタが利用可能かを示す情報は
1285 ないので、どのファイルディスクリプタで I/O が可能かを判断するためには
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
1301 .\"O is set for the signal handler, as above.
1305 同じシグナル番号を持つ複数の I/O イベントがキューに入ることがある
1306 (キューに入れるかどうかは利用可能なメモリに依存している)。
1309 が設定されている場合、シグナルハンドラのための追加の情報が得られる。
1311 .\"O Note that Linux imposes a limit on the
1312 .\"O number of real-time signals that may be queued to a
1314 .\"O .BR getrlimit (2)
1316 .\"O .BR signal (7))
1317 .\"O and if this limit is reached, then the kernel reverts to
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
1324 Linux では一つのプロセスに対してキューに入れられるリアルタイム
1333 シグナルは、指定されたスレッドではなくプロセス全体に送られる。
1335 .\"O Using these mechanisms, a program can implement fully asynchronous I/O
1340 .\"O most of the time.
1341 これらの機構を使用することで、ほとんどの場合で
1345 を使用せずに完全な非同期 I/O を実装することができる。
1351 .\"O is specific to BSD and Linux.
1355 の使用は BSD と Linux に特有である。
1356 .\"O .BR F_GETOWN_EX ,
1357 .\"O .BR F_SETOWN_EX ,
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).
1370 は Linux 固有である。POSIX には、同様のことを行うために、非同期 I/O と
1372 構造体がある。Linux では、GNU C ライブラリ (Glibc) の一部として
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
1387 が参照するオープンファイル記述に対して新しいリースを設定するのに使用される。
1391 が参照するオープンファイル記述に対して設定されている
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
1398 .\"O .BR truncate (2)
1399 .\"O the file referred to by that file descriptor.
1401 あるプロセス ("lease breaker") がそのファイルディスクリプタが参照
1406 を行おうとした際に、リースを保持しているプロセス ("lease holder") へ
1407 (シグナルの配送による) 通知が行われるという機構が提供される。
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
1414 の内容に基いてファイルのリースの設定、削除を行う。整数
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.
1429 そのファイルが書き込み用にオープンされたり、ファイルが切り詰められた場合に、
1430 呼び出し元のプロセスに通知が行われるようになる。
1431 .\" 以下の内容はカーネル 2.6.10 で実装された。
1432 .\" より詳しい情報は man-pages-2.09 の Changelog を参照。
1433 読み出しリースを設定できるのは、読み出し専用でオープンされている
1434 ファイルディスクリプタに対してのみである。
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.
1443 (読み出し用か書き込み用にかかわらず) そのファイルがオープンされたり、
1444 ファイルが切り詰められた場合に、呼び出し元のプロセスに通知が行われるようになる。
1445 書き込みリースは、そのファイルに対するオープンされたファイルディスクリプタが
1449 .\"O Remove our lease from the file.
1453 .\"O Leases are associated with an open file description (see
1455 .\"O This means that duplicate file descriptors (created by, for example,
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
1463 .\"O operation on any of these duplicate descriptors, or when all
1464 .\"O such descriptors have been closed.
1465 リースはオープンファイル記述に対して関連付けられる
1472 などにより作成された) ファイルディスクリプタの複製は同じリースを参照し、
1473 複製も含めたどのファイルディスクリプタを使ってもこのリースを変更したり
1475 また、これらのファイルディスクリプタのいずれかに対して
1477 操作が明示的に実行された場合や、すべてのファイルディスクリプタが
1478 閉じられた場合にも、リースは解放される。
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
1485 .\"O capability may take out leases on arbitrary files.
1486 リースの取得は通常のファイル (regular file) に対してのみ可能である。
1487 非特権プロセスがリースを取得できるのは、UID (所有者) がプロセスの
1488 ファイルシステム UID と一致するファイルに対してだけである。
1490 ケーパビリティを持つプロセスは任意のファイルに対してリースを取得できる。
1492 .BR F_GETLEASE " (\fIvoid\fP)"
1493 .\"O Indicates what type of lease is associated with the file descriptor
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.
1502 に対して設定されているリースの種別を取得する。
1503 .BR F_RDLCK ", " F_WRLCK ", " F_UNLCK
1505 .BR F_RDLCK ", " F_WRLCK
1506 はそれぞれ、読み出しリース、書き込みリースが設定されていることを示し、
1508 はリースが何も設定されていないことを示す。
1512 .\"O When a process (the "lease breaker") performs an
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
1522 あるプロセス ("lease folder") が
1529 そのシステムコールはカーネルによって停止され、
1530 カーネルは lease holder にシグナル (デフォルトでは
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
1543 .\"O command specifying
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
1560 .\"O command specifying
1564 lease holder がファイルに書き込みリースを保持していて、
1565 lease breaker が読み出し用にそのファイルをオープンしている場合、
1566 lease holder が保持しているリースを読み出しリースに格下げすれば
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.
1580 .I /proc/sys/fs/lease-break-time
1581 で指定された秒数以内にリースの格下げか削除を行えなかった場合、
1582 カーネルは強制的にその lease holder のリースを削除もしくは格下げを行う。
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 のシステムコールの続行を許可する。
1591 .\"O If the lease breaker's blocked
1594 .\"O .BR truncate (2)
1595 .\"O is interrupted by a signal handler,
1596 .\"O then the system call fails with the error
1598 .\"O but the other steps still occur as described above.
1603 が停止中にシグナルハンドラにより中断された場合、
1606 エラーで失敗するが、上で述べた他の処理は
1608 .\"O If the lease breaker is killed by a signal while blocked in
1611 .\"O .BR truncate (2),
1612 .\"O then the other steps still occur as described above.
1616 が停止中に lease breaker がシグナルにより kill された場合、
1618 .\"O If the lease breaker specifies the
1620 .\"O flag when calling
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.
1629 フラグを指定した場合、そのシステムコールは
1631 エラーで直ちに失敗するが、上で述べた他の処理はそのまま行われる。
1633 .\"O The default signal used to notify the lease holder is
1635 .\"O but this can be changed using the
1641 .\"O command is performed (even one specifying
1644 .\"O handler is established using
1645 .\"O .BR SA_SIGINFO ,
1646 .\"O then the handler will receive a
1648 .\"O structure as its second argument, and the
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 への通知に使われるデフォルトのシグナルは
1665 フラグ付きでシグナルハンドラが設定されている場合には、
1670 フィールドには別のプロセスがアクセスしたリース設定済みファイルの
1672 (この機能は複数のファイルに対してリースを設定する場合に有用である)。
1673 .\"O .SS "File and directory change notification (dnotify)"
1674 .SS "ファイルやディレクトリの変更の通知 (dnotify)"
1676 .BR F_NOTIFY " (\fIlong\fP)"
1677 .\"O (Linux 2.4 onwards)
1679 .\"O Provide notification when the directory referred to by
1681 .\"O or any of the files that it contains is changed.
1682 .\"O The events to be notified are specified in
1684 .\"O which is a bit mask specified by ORing together zero or more of
1685 .\"O the following bits:
1687 で参照されるディレクトリか、その中にあるファイルに変更があった場合に
1692 はビットマスクで、以下のビットの 0個以上の論理和をとったものを指定する。
1698 .\"O A file was accessed (read, pread, readv)
1699 ファイルへのアクセスがあった (read, pread, readv)
1702 .\"O A file was modified (write, pwrite, writev, truncate, ftruncate).
1703 ファイルの内容が変更された (write, pwrite, writev, truncate, ftruncate).
1706 .\"O A file was created (open, creat, mknod, mkdir, link, symlink, rename).
1707 ファイルが作成された (open, creat, mknod, mkdir, link, symlink, rename).
1710 .\"O A file was unlinked (unlink, rename to another directory, rmdir).
1711 ファイルが削除 (unlink) された (unlink, 別のディレクトリへの rename, rmdir)
1714 .\"O A file was renamed within this directory (rename).
1715 ディレクトリ内でのファイル名の変更があった (rename)
1718 .\"O The attributes of a file were changed (chown, chmod, utime[s]).
1719 ファイル属性が変更された (chown, chmod, utime[s])
1723 .\"O (In order to obtain these definitions, the
1725 .\"O feature test macro must be defined.)
1728 機能検査マクロを定義しなければならない。)
1730 .\"O Directory notifications are normally "one-shot", and the application
1731 .\"O must reregister to receive further notifications.
1732 ディレクトリの変更通知は通常「一回限り (one-shot)」であり、
1733 アプリケーション側でその後さらに通知を受信したい場合は
1735 .\"O Alternatively, if
1736 .\"O .B DN_MULTISHOT
1739 .\"O then notification will remain in effect until explicitly removed.
1744 変更通知は明示的に解除されるまで有効状態が継続する。
1746 .\"O .\" The following does seem a poor API-design choice...
1747 .\" 以下は API の設計がまずいと思うのだが...
1750 .\"O requests is cumulative, with the events in
1752 .\"O being added to the set already monitored.
1756 で指定されたイベントがすでにモニタされている
1758 .\"O To disable notification of all events, make an
1760 .\"O call specifying
1763 すべてのイベントの通知を無効にするには、
1769 .\"O Notification occurs via delivery of a signal.
1771 .\"O The default signal is
1773 .\"O but this can be changed using the
1784 .\"O In the latter case, the signal handler receives a
1786 .\"O structure as its second argument (if the handler was
1787 .\"O established using
1788 .\"O .BR SA_SIGINFO )
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).
1796 フラグ付きでシグナルハンドラが設定されている場合には)
1801 フィールドには通知の行われたファイルディスクリプタが入っている
1802 (この機能は複数のディレクトリに対して通知を設定する場合に有用である)。
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.
1810 を使う場合は、通知にはリアルタイムシグナルを使うべきである。
1811 それは、リアルタイムシグナルを使うことで、複数の通知をキューに入れる
1815 .\"O New applications should use the
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.
1821 .\"O .BR inotify (7).
1823 新しくアプリケーションを書く際には、(カーネル 2.6.13 以降で利用可能となった)
1827 はファイルシステムイベントの通知を取得するための
1831 .\"O .SH "RETURN VALUE"
1833 .\"O For a successful call, the return value depends on the operation:
1834 成功した場合の返り値は操作の種類により違う:
1837 .\"O The new descriptor.
1841 .\"O Value of file descriptor flags.
1842 ファイルディスクリプタ・フラグの値を返す。
1845 .\"O Value of file status flags.
1849 .\"O Type of lease held on file descriptor.
1850 ファイルディスクリプタに対して保持されているリースの種別を返す。
1853 .\"O Value of descriptor owner.
1857 .\"O Value of signal sent when read or write becomes possible, or zero
1858 .\"O for traditional
1861 読み込みや書き出しが可能になった時に送られるシグナルの値、もしくは
1866 .\"O All other commands
1870 .\"O On error, \-1 is returned, and
1872 .\"O is set appropriately.
1879 .\"O .BR EACCES " or " EAGAIN
1880 .BR EACCES " か " EAGAIN
1881 .\"O Operation is prohibited by locks held by other processes.
1882 他のプロセスが保持しているロックによって操作が禁止されている。
1885 .\"O The operation is prohibited because the file has been memory-mapped by
1886 .\"O another process.
1887 そのファイルは他のプロセスによってメモリ・マップされているため、
1892 .\"O is not an open file descriptor, or the command was
1896 .\"O and the file descriptor open mode doesn't match with the
1897 .\"O type of lock requested.
1899 がオープンされたファイルディスクリプタでない。
1904 だったが、対象のファイルディスクリプタのオープンモードが
1905 必要となるロックの型にマッチしていない。
1908 .\"O It was detected that the specified
1910 .\"O command would cause a deadlock.
1914 コマンドを実行した場合にはデッドロックになることが検出された。
1918 .\"O is outside your accessible address space.
1925 .\"O the command was interrupted by a signal; see
1926 .\"O .BR signal (7).
1928 .\"O .BR F_GETLK " and " F_SETLK ,
1929 .\"O the command was interrupted by a signal before the lock was checked or
1931 .\"O Most likely when locking a remote file (e.g., locking over
1932 .\"O NFS), but can sometimes happen locally.
1937 .BR F_GETLK " と " F_SETLK
1938 の場合、ロックを確認したり取得したりする前にシグナルによって割り込まれた。
1939 これはたいていリモートのファイルをロックする場合
1940 (例えば NFS 上でロックする場合) に起こる。
1947 .\"O is negative or is greater than the maximum allowable value.
1951 .\"O is not an allowable signal number.
1954 が負か、もしくは許される最大値よりも大きい。
1963 .\"O the process already has the maximum number of file descriptors open.
1965 プロセスがすでに最大数までファイルディスクリプタをオープンしている。
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 上のロック) が失敗した。
1974 .\"O Attempted to clear the
1976 .\"O flag on a file that has the append-only attribute set.
1980 .\"O .SH "CONFORMING TO"
1982 .\"O SVr4, 4.3BSD, POSIX.1-2001.
1983 SVr4, 4.3BSD, POSIX.1-2001.
1984 .\"O Only the operations
1996 .\"O are specified in POSIX.1-2001.
1997 POSIX.1-2001 で規定されている操作は、
2010 .\"O .B F_DUPFD_CLOEXEC
2011 .\"O is specified in POSIX.1-2008.
2013 は POSIX.1-2008 で規定されている。
2015 .\"O .BR F_GETOWN_EX ,
2016 .\"O .BR F_SETOWN_EX ,
2020 .\"O .BR F_GETLEASE ,
2023 .\"O are Linux-specific.
2026 .\"O macro to obtain these definitions.)
2034 は Linux 固有である (これらの定義を有効にするには
2038 .\"O .\" SVr4 documents additional EIO, ENOLINK and EOVERFLOW error conditions.
2039 .\" SVr4 には他に EFAULT, EINTR, EIO, ENOLINK, EOVERFLOW エラー状態についての
2043 .\"O The errors returned by
2045 .\"O are different from those returned by
2053 .\"O Since kernel 2.0, there is no interaction between the types of lock
2062 が設定するロック種別の間に相互作用はない。
2064 .\"O Several systems have more fields in
2065 .\"O .I "struct flock"
2066 .\"O such as, for example,
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
2072 .\"O alone is not going to be very useful if the process holding the lock
2073 .\"O may live on a different machine.
2076 に上記以外のフィールドがあるものもある (例えば
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 はっきりと言えることは、ロックを保持しているプロセスが別のマシンに存在
2083 だけはあまり役にたたないだろうということである。
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
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
2095 .\"O will be \-1, and
2097 .\"O will contain the (positive) process group ID.
2098 いくつかのアーキテクチャ (特に i386) における Linux システムコールの慣習
2101 が返す (負の) プロセスグループID が \-1 から \-4095 の範囲に入った場合、
2102 glibc はこの返り値をシステムコールでエラーが起こったと
2107 には (正の) プロセスグループID が設定されることになる。
2108 .\"O The Linux-specific
2109 .\"O .BR F_SETOWN_EX
2111 .\"O .BR F_GETOWN_EX
2112 .\"O operations avoid this problem.
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 と同様の範囲のチェックが行われているようだ。
2127 .\"O In Linux 2.4 and earlier, there is bug that can occur
2128 .\"O when an unprivileged process uses
2130 .\"O to specify the owner
2131 .\"O of a socket file descriptor
2132 .\"O as a process (group) other than the caller.
2135 .\"O can return \-1 with
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 以前では、非特権プロセスが
2145 を使って、ソケットのファイルディスクリプタの所有者に
2146 呼び出し元以外のプロセス (やプロセスグループ) を指定すると
2148 呼び出し元が所有者として指定したプロセス (やプロセスグループ) に
2149 シグナルを送る許可を持っていたとしても、
2156 このエラーが返ったにもかかわらず、ファイルディスクリプタの所有者
2157 は設定され、シグナルはその所有者に送られる。
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
2164 .\"O call that overlaps with a lock may modify data after the mandatory lock is
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
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
2178 の呼び出しは強制ロックが獲得された後にもデータを変更することができる。
2181 の呼び出しは強制ロックが獲得された後になって行われたデータの変更を
2185 の間にも存在する。それゆえ、強制ロックに頼るのはお薦めできない。
2193 .BR capabilities (7),
2194 .BR feature_test_macros (7)
2197 .\"O .IR locks.txt ,
2198 .\"O .IR mandatory-locking.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/
2206 .\"O .I mandatory-locking.txt
2208 .\"O .IR mandatory.txt .)
2210 .IR Documentation/filesystems/
2213 .IR mandatory-locking.txt ,
2216 (以前のカーネルでは、これらのファイルは
2219 .I mandatory-locking.txt