#, fuzzy msgid "" msgstr "" "Project-Id-Version: man-pages-l10n VERSION\n" "POT-Creation-Date: 2014-07-17 17:53+0900\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: TH #: man-pages/man2/fcntl.2:62 #, no-wrap msgid "FCNTL" msgstr "" #. type: TH #: man-pages/man2/fcntl.2:62 #, no-wrap msgid "2014-07-08" msgstr "" #. type: TH #: man-pages/man2/fcntl.2:62 #, no-wrap msgid "Linux" msgstr "" #. type: TH #: man-pages/man2/fcntl.2:62 #, no-wrap msgid "Linux Programmer's Manual" msgstr "" #. type: SH #: man-pages/man2/fcntl.2:63 #, no-wrap msgid "NAME" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:65 msgid "fcntl - manipulate file descriptor" msgstr "" #. type: SH #: man-pages/man2/fcntl.2:65 #, no-wrap msgid "SYNOPSIS" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:69 #, no-wrap msgid "B<#include Eunistd.hE>\n" "B<#include Efcntl.hE>\n" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:71 #, no-wrap msgid "BIB<, int >IB<, ... /* >IB< */ );>\n" msgstr "" #. type: SH #: man-pages/man2/fcntl.2:72 #, no-wrap msgid "DESCRIPTION" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:78 msgid "" "B() performs one of the operations described below on the open file " "descriptor I. The operation is determined by I." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:92 msgid "" "B() can take an optional third argument. Whether or not this " "argument is required is determined by I. The required argument type is " "indicated in parentheses after each I name (in most cases, the required " "type is I, and we identify the argument using the name I), or " "I is specified if the argument is not required." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:103 msgid "" "Certain of the operations below are supported only since a particular Linux " "kernel version. The preferred method of checking whether the host kernel " "supports a particular operation is to invoke B() with the desired " "I value and then test whether the call failed with B, " "indicating that the kernel does not recognize this value." msgstr "" #. type: SS #: man-pages/man2/fcntl.2:103 #, no-wrap msgid "Duplicating a file descriptor" msgstr "" #. type: TP #: man-pages/man2/fcntl.2:104 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:114 msgid "" "Find the lowest numbered available file descriptor greater than or equal to " "I and make it be a copy of I. This is different from B(2), " "which uses exactly the descriptor specified." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:116 msgid "On success, the new descriptor is returned." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:120 msgid "See B(2) for further details." msgstr "" #. type: TP #: man-pages/man2/fcntl.2:120 #, no-wrap msgid "B (I; since Linux 2.6.24)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:137 msgid "" "As for B, but additionally set the close-on-exec flag for the " "duplicate descriptor. Specifying this flag permits a program to avoid an " "additional B() B operation to set the B flag. " "For an explanation of why this flag is useful, see the description of " "B in B(2)." msgstr "" #. type: SS #: man-pages/man2/fcntl.2:137 #, no-wrap msgid "File descriptor flags" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:148 msgid "" "The following commands manipulate the flags associated with a file " "descriptor. Currently, only one such flag is defined: B, the " "close-on-exec flag. If the B bit is 0, the file descriptor will " "remain open across an B(2), otherwise it will be closed." msgstr "" #. type: TP #: man-pages/man2/fcntl.2:148 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:153 msgid "Read the file descriptor flags; I is ignored." msgstr "" #. type: TP #: man-pages/man2/fcntl.2:153 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:157 msgid "Set the file descriptor flags to the value specified by I." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:172 msgid "" "In multithreaded programs, using B() B to set the close-on-" "exec flag at the same time as another thread performs a B(2) plus " "B(2) is vulnerable to a race condition that may unintentionally " "leak the file descriptor to the program executed in the child process. See " "the discussion of the B flag in B(2) for details and a " "remedy to the problem." msgstr "" #. type: SS #: man-pages/man2/fcntl.2:172 #, no-wrap msgid "File status flags" msgstr "" #. or #. .BR creat (2), #. type: Plain text #: man-pages/man2/fcntl.2:187 msgid "" "Each open file description has certain associated status flags, initialized " "by B(2) and possibly modified by B(). Duplicated file " "descriptors (made with B(2), B(F_DUPFD), B(2), etc.) refer " "to the same open file description, and thus share the same file status flags." "" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:190 msgid "The file status flags and their semantics are described in B(2)." msgstr "" #. type: TP #: man-pages/man2/fcntl.2:190 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:195 msgid "Get the file access mode and the file status flags; I is ignored." msgstr "" #. type: TP #: man-pages/man2/fcntl.2:195 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:220 msgid "" "Set the file status flags to the value specified by I. File access " "mode (B, B, B) and file creation flags (i.e., " "B, B, B, B) in I are ignored. On " "Linux this command can change only the B, B, B, " "B, and B flags. It is not possible to change the " "B and B flags; see BUGS, below." msgstr "" #. type: SS #: man-pages/man2/fcntl.2:220 #, no-wrap msgid "Advisory record locking" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:225 msgid "" "Linux implements traditional (\"process-associated\") UNIX record locks, as " "standardized by POSIX. For a Linux-specific alternative with better " "semantics, see the discussion of open file description locks below." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:236 msgid "" "B, B, and B are used to acquire, release, and " "test for the existence of record locks (also known as byte-range, file-" "segment, or file-region locks). The third argument, I, is a pointer " "to a structure that has at least the following fields (in unspecified order)." "" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:251 #, no-wrap msgid "" "struct flock {\n" " ...\n" " short l_type; /* Type of lock: F_RDLCK,\n" " F_WRLCK, F_UNLCK */\n" " short l_whence; /* How to interpret l_start:\n" " SEEK_SET, SEEK_CUR, SEEK_END */\n" " off_t l_start; /* Starting offset for lock */\n" " off_t l_len; /* Number of bytes to lock */\n" " pid_t l_pid; /* PID of process blocking our lock\n" " (set by F_GETLK and F_OFD_GETLK) */\n" " ...\n" "};\n" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:259 msgid "" "The I, I, and I fields of this structure specify " "the range of bytes we wish to lock. Bytes past the end of the file may be " "locked, but not bytes before the start of the file." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:279 msgid "" "I is the starting offset for the lock, and is interpreted relative " "to either: the start of the file (if I is B); the " "current file offset (if I is B); or the end of the file " "(if I is B). In the final two cases, I can be " "a negative number provided the offset does not lie before the start of the " "file." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:294 msgid "" "I specifies the number of bytes to be locked. If I is " "positive, then the range to be locked covers bytes I up to and " "including I+I-1. Specifying 0 for I has the special " "meaning: lock all bytes starting at the location specified by I " "and I through to the end of file, no matter how large the file " "grows." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:307 msgid "" "POSIX.1-2001 allows (but does not require) an implementation to support a " "negative I value; if I is negative, the interval described by " "I covers bytes I+I up to and including I-1. " "This is supported by Linux since kernel versions 2.4.21 and 2.5.49." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:326 msgid "" "The I field can be used to place a read (B) or a write " "(B) lock on a file. Any number of processes may hold a read lock " "(shared lock) on a file region, but only one process may hold a write lock " "(exclusive lock). An exclusive lock excludes all other locks, both shared " "and exclusive. A single process can hold only one type of lock on a file " "region; if a new lock is applied to an already-locked region, then the " "existing lock is converted to the new lock type. (Such conversions may " "involve splitting, shrinking, or coalescing with an existing lock if the " "byte range specified by the new lock does not precisely coincide with the " "range of the existing lock.)" msgstr "" #. type: TP #: man-pages/man2/fcntl.2:326 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:351 msgid "" "Acquire a lock (when I is B or B) or release a " "lock (when I is B) on the bytes specified by the " "I, I, and I fields of I. If a conflicting " "lock is held by another process, this call returns -1 and sets I to " "B or B. (The error returned in this case differs across " "implementations, so POSIX requires a portable application to check for both " "errors.)" msgstr "" #. type: TP #: man-pages/man2/fcntl.2:351 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:365 msgid "" "As for B, but if a conflicting lock is held on the file, then wait " "for that lock to be released. If a signal is caught while waiting, then the " "call is interrupted and (after the signal handler has returned) returns " "immediately (with return value -1 and I set to B; see " "B(7))." msgstr "" #. type: TP #: man-pages/man2/fcntl.2:365 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:379 msgid "" "On input to this call, I describes a lock we would like to place on " "the file. If the lock could be placed, B() does not actually place " "it, but returns B in the I field of I and leaves the " "other fields of the structure unchanged." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:396 msgid "" "If one or more incompatible locks would prevent this lock being placed, then " "B() returns details about one of those locks in the I, " "I, I, and I fields of I. If the conflicting " "lock is a traditional (process-associated) record lock, then the I " "field is set to the PID of the process holding that lock. If the " "conflicting lock is an open file description lock, then I is set to -" "1. Note that the returned information may already be out of date by the " "time the caller inspects it." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:404 msgid "" "In order to place a read lock, I must be open for reading. In order to " "place a write lock, I must be open for writing. To place both types of " "lock, open a file read-write." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:427 msgid "" "When placing locks with B, the kernel detects I, " "whereby two or more processes have their lock requests mutually blocked by " "locks held by the other processes. For example, suppose process A holds a " "write lock on byte 100 of a file, and process B holds a write lock on byte " "200. If each process then attempts to lock the byte already locked by the " "other process using B, then, without deadlock detection, both " "processes would remain blocked indefinitely. When the kernel detects such " "deadlocks, it causes one of the blocking lock requests to immediately fail " "with the error B; an application that encounters such an error " "should release some of its locks to allow other applications to proceed " "before attempting regain the locks that it requires. Circular deadlocks " "involving more than two processes are also detected. Note, however, that " "there are limitations to the kernel's deadlock-detection algorithm; see BUGS." "" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:431 msgid "" "As well as being removed by an explicit B, record locks are " "automatically released when the process terminates." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:436 msgid "" "Record locks are not inherited by a child created via B(2), but are " "preserved across an B(2)." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:445 msgid "" "Because of the buffering performed by the B(3) library, the use of " "record locking with routines in that package should be avoided; use " "B(2) and B(2) instead." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:449 msgid "" "The record locks described above are associated with the process (unlike the " "open file description locks described below). This has some unfortunate " "consequences:" msgstr "" #. type: IP #: man-pages/man2/fcntl.2:449 man-pages/man2/fcntl.2:465 #, no-wrap msgid "*" msgstr "" #. (Additional file descriptors referring to the same file #. may have been obtained by calls to #. .BR open "(2), " dup "(2), " dup2 "(2), or " fcntl ().) #. type: Plain text #: man-pages/man2/fcntl.2:465 msgid "" "If a process closes I file descriptor referring to a file, then all of " "the process's locks on that file are released, regardless of the file " "descriptor(s) on which the locks were obtained. This is bad: it means that " "a process can lose its locks on a file such as I or I when for some reason a library function decides to open, read, and " "close the same file." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:470 msgid "" "The threads in a process share locks. In other words, a multithreaded " "program can't use record locking to ensure that threads don't simultaneously " "access the same region of a file." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:472 msgid "Open file description locks solve both of these problems." msgstr "" #. type: SS #: man-pages/man2/fcntl.2:472 #, no-wrap msgid "Open file description locks (non-POSIX)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:479 msgid "" "Open file description locks are advisory byte-range locks whose operation is " "in most respects identical to the traditional record locks described above. " "This lock type is Linux-specific, and available since Linux 3.15. For an " "explanation of open file descriptions, see B(2)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:497 msgid "" "The principal difference between the two lock types is that whereas " "traditional record locks are associated with a process, open file " "description locks are associated with the open file description on which " "they are acquired, much like locks acquired with B(2). Consequently " "(and unlike traditional advisory record locks), open file description locks " "are inherited across B(2) (and B(2) with B), and " "are only automatically released on the last close of the open file " "description, instead of being released on any close of the file." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:500 msgid "" "Open file description locks always conflict with traditional record locks, " "even when they are acquired by the same process on the same file descriptor." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:513 msgid "" "Open file description locks placed via the same open file description (i.e., " "via the same file descriptor, or via a duplicate of the file descriptor " "created by B(2), B(2), B(2) B, and so on) are " "always compatible: if a new lock is placed on an already locked region, then " "the existing lock is converted to the new lock type. (Such conversions may " "result in splitting, shrinking, or coalescing with an existing lock as " "discussed above.)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:521 msgid "" "On the other hand, open file description locks may conflict with each other " "when they are acquired via different open file descriptions. Thus, the " "threads in a multithreaded program can use open file description locks to " "synchronize access to a file region by having each thread perform its own " "B(2) on the file and applying locks via the resulting file descriptor." "" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:532 msgid "" "As with traditional advisory locks, the third argument to B(), " "I, is a pointer to an I structure. By contrast with " "traditional record locks, the I field of that structure must be set " "to zero when using the commands described below." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:535 msgid "" "The commands for working with open file description locks are analogous to " "those used with traditional locks:" msgstr "" #. type: TP #: man-pages/man2/fcntl.2:535 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:556 msgid "" "Acquire an open file description lock (when I is B or " "B) or release an open file description lock (when I is " "B) on the bytes specified by the I, I, and " "I fields of I. If a conflicting lock is held by another " "process, this call returns -1 and sets I to B." msgstr "" #. type: TP #: man-pages/man2/fcntl.2:556 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:570 msgid "" "As for B, but if a conflicting lock is held on the file, then " "wait for that lock to be released. If a signal is caught while waiting, " "then the call is interrupted and (after the signal handler has returned) " "returns immediately (with return value -1 and I set to B; see " "B(7))." msgstr "" #. type: TP #: man-pages/man2/fcntl.2:570 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:589 msgid "" "On input to this call, I describes an open file description lock we " "would like to place on the file. If the lock could be placed, B() " "does not actually place it, but returns B in the I field of " "I and leaves the other fields of the structure unchanged. If one or " "more incompatible locks would prevent this lock being placed, then details " "about one of these locks are returned via I, as described above for " "B." msgstr "" #. commit 57b65325fe34ec4c917bc4e555144b4a94d9e1f7 #. type: Plain text #: man-pages/man2/fcntl.2:596 msgid "" "In the current implementation, no deadlock detection is performed for open " "file description locks. (This contrasts with process-associated record " "locks, for which the kernel does perform deadlock detection.)" msgstr "" #. type: SS #: man-pages/man2/fcntl.2:596 man-pages/man2/fcntl.2:1667 #, no-wrap msgid "Mandatory locking" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:600 msgid "" "I: the Linux implementation of mandatory locking is unreliable. " "See BUGS below." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:605 msgid "" "By default, both traditional (process-associated) and open file description " "record locks are advisory. Advisory locks are not enforced and are useful " "only between cooperating processes." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:625 msgid "" "Both lock types can also be mandatory. Mandatory locks are enforced for all " "processes. If a process tries to perform an incompatible access (e.g., " "B(2) or B(2)) on a file region that has an incompatible " "mandatory lock, then the result depends upon whether the B flag " "is enabled for its open file description. If the B flag is not " "enabled, then the system call is blocked until the lock is removed or " "converted to a mode that is compatible with the access. If the " "B flag is enabled, then the system call fails with the error " "B." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:642 msgid "" "To make use of mandatory locks, mandatory locking must be enabled both on " "the filesystem that contains the file to be locked, and on the file itself. " "Mandatory locking is enabled on a filesystem using the \"-o mand\" option to " "B(8), or the B flag for B(2). Mandatory locking " "is enabled on a file by disabling group execute permission on the file and " "enabling the set-group-ID permission bit (see B(1) and B(2))." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:646 msgid "" "Mandatory locking is not specified by POSIX. Some other systems also " "support mandatory locking, although the details of how to enable it vary " "across systems." msgstr "" #. type: SS #: man-pages/man2/fcntl.2:646 #, no-wrap msgid "Managing signals" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:655 msgid "" "B, B, B, B, B and " "B are used to manage I/O availability signals:" msgstr "" #. type: TP #: man-pages/man2/fcntl.2:655 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:668 msgid "" "Return (as the function result) the process ID or process group currently " "receiving B and B signals for events on file descriptor I." " Process IDs are returned as positive values; process group IDs are " "returned as negative values (but see BUGS below). I is ignored." msgstr "" #. type: TP #: man-pages/man2/fcntl.2:668 #, no-wrap msgid "B (I)" msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:685 msgid "" "Set the process ID or process group ID that will receive B and " "B signals for events on file descriptor I to the ID given in " "I. A process ID is specified as a positive value; a process group ID " "is specified as a negative value. Most commonly, the calling process " "specifies itself as the owner (that is, I is specified as B(2))." "" msgstr "" #. From glibc.info: #. type: Plain text #: man-pages/man2/fcntl.2:702 msgid "" "If you set the B status flag on a file descriptor by using the " "B command of B(), a B signal is sent whenever input " "or output becomes possible on that file descriptor. B can be used " "to obtain delivery of a signal other than B. If this permission " "check fails, then the signal is silently discarded." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:710 msgid "" "Sending a signal to the owner process (group) specified by B is " "subject to the same permissions checks as are described for B(2), " "where the sending process is the one that employs B (but see BUGS " "below)." msgstr "" #. The following appears to be rubbish. It doesn't seem to #. be true according to the kernel source, and I can write #. a program that gets a terminal-generated SIGIO even though #. it is not the foreground process group of the terminal. #. -- MTK, 8 Apr 05 #. If the file descriptor #. .I fd #. refers to a terminal device, then SIGIO #. signals are sent to the foreground process group of the terminal. #. type: Plain text #: man-pages/man2/fcntl.2:734 msgid "" "If the file descriptor I refers to a socket, B also selects " "the recipient of B signals that are delivered when out-of-band data " "arrives on that socket. (B is sent in any situation where " "B(2), B(2), B(2) with B set etc.) to " "determine which file descriptors are available for I/O." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:936 msgid "" "By selecting a real time signal (value E= B), multiple I/O " "events may be queued using the same signal numbers. (Queuing is dependent " "on available memory). Extra information is available if B is " "set for the signal handler, as above." msgstr "" #. See fs/fcntl.c::send_sigio_to_task() (2.4/2.6) sources -- MTK, Apr 05 #. type: Plain text #: man-pages/man2/fcntl.2:949 msgid "" "Note that Linux imposes a limit on the number of real-time signals that may " "be queued to a process (see B(2) and B(7)) and if this " "limit is reached, then the kernel reverts to delivering B, and this " "signal is delivered to the entire process rather than to a specific thread." msgstr "" #. type: Plain text #: man-pages/man2/fcntl.2:956 msgid "" "Using these mechanisms, a program can implement fully asynchronous I/O " "without using B