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-2010 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
58 .\" 2010-06-17, Michael Kerrisk
59 .\" Document F_SETPIPE_SZ and F_GETPIPE_SZ.
61 .TH FCNTL 2 2010-11-21 "Linux" "Linux Programmer's Manual"
63 fcntl \- manipulate file descriptor
66 .B #include <unistd.h>
69 .BI "int fcntl(int " fd ", int " cmd ", ... /* " arg " */ );"
73 performs one of the operations described below on the open file descriptor
75 The operation is determined by
79 can take an optional third argument.
80 Whether or not this argument is required is determined by
82 The required argument type is indicated in parentheses after each
84 name (in most cases, the required type is
86 and we identify the argument using the name
90 is specified if the argument is not required.
91 .SS "Duplicating a file descriptor"
93 .BR F_DUPFD " (\fIlong\fP)"
94 Find the lowest numbered available file descriptor
95 greater than or equal to
97 and make it be a copy of
99 This is different from
101 which uses exactly the descriptor specified.
103 On success, the new descriptor is returned.
109 .BR F_DUPFD_CLOEXEC " (\fIlong\fP; since Linux 2.6.24)"
112 but additionally set the
113 close-on-exec flag for the duplicate descriptor.
114 Specifying this flag permits a program to avoid an additional
120 For an explanation of why this flag is useful,
121 see the description of
125 .SS "File descriptor flags"
126 The following commands manipulate the flags associated with
128 Currently, only one such flag is defined:
130 the close-on-exec flag.
133 bit is 0, the file descriptor will remain open across an
135 otherwise it will be closed.
137 .BR F_GETFD " (\fIvoid\fP)"
138 Read the file descriptor flags;
142 .BR F_SETFD " (\fIlong\fP)"
143 Set the file descriptor flags to the value specified by
145 .SS "File status flags"
146 Each open file description has certain associated status flags,
151 and possibly modified by
153 Duplicated file descriptors
158 etc.) refer to the same open file description, and thus
159 share the same file status flags.
161 The file status flags and their semantics are described in
164 .BR F_GETFL " (\fIvoid\fP)"
165 Read the file status flags;
169 .BR F_SETFL " (\fIlong\fP)"
170 Set the file status flags to the value specified by
173 .RB ( O_RDONLY ", " O_WRONLY ", " O_RDWR )
174 and file creation flags
176 .BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", " O_TRUNC )
180 On Linux this command can only change the
188 .\" FIXME . According to POSIX.1-2001, O_SYNC should also be modifiable
189 .\" via fcntl(2), but currently Linux does not permit this
190 .\" See http://bugzilla.kernel.org/show_bug.cgi?id=5994
191 .SS "Advisory locking"
192 .BR F_GETLK ", " F_SETLK " and " F_SETLKW
193 are used to acquire, release, and test for the existence of record
194 locks (also known as file-segment or file-region locks).
197 is a pointer to a structure that has at least the following fields
198 (in unspecified order).
204 short l_type; /* Type of lock: F_RDLCK,
206 short l_whence; /* How to interpret l_start:
207 SEEK_SET, SEEK_CUR, SEEK_END */
208 off_t l_start; /* Starting offset for lock */
209 off_t l_len; /* Number of bytes to lock */
210 pid_t l_pid; /* PID of process blocking our lock
218 .IR l_whence ", " l_start ", and " l_len
219 fields of this structure specify the range of bytes we wish to lock.
220 Bytes past the end of the file may be locked,
221 but not bytes before the start of the file.
224 is the starting offset for the lock, and is interpreted
226 the start of the file (if
230 the current file offset (if
234 or the end of the file (if
238 In the final two cases,
240 can be a negative number provided the
241 offset does not lie before the start of the file.
244 specifies the number of bytes to be locked.
247 is positive, then the range to be locked covers bytes
250 .IR l_start + l_len \- 1 .
253 has the special meaning: lock all bytes starting at the
254 location specified by
255 .IR l_whence " and " l_start
256 through to the end of file, no matter how large the file grows.
258 POSIX.1-2001 allows (but does not require)
259 an implementation to support a negative
263 is negative, the interval described by
269 This is supported by Linux since kernel versions 2.4.21 and 2.5.49.
273 field can be used to place a read
278 Any number of processes may hold a read lock (shared lock)
279 on a file region, but only one process may hold a write lock
281 An exclusive lock excludes all other locks,
282 both shared and exclusive.
283 A single process can hold only one type of lock on a file region;
284 if a new lock is applied to an already-locked region,
285 then the existing lock is converted to the new lock type.
286 (Such conversions may involve splitting, shrinking, or coalescing with
287 an existing lock if the byte range specified by the new lock does not
288 precisely coincide with the range of the existing lock.)
290 .BR F_SETLK " (\fIstruct flock *\fP)"
297 or release a lock (when
301 on the bytes specified by the
302 .IR l_whence ", " l_start ", and " l_len
305 If a conflicting lock is held by another process,
306 this call returns \-1 and sets
313 .BR F_SETLKW " (\fIstruct flock *\fP)"
316 but if a conflicting lock is held on the file, then wait for that
318 If a signal is caught while waiting, then the call is interrupted
319 and (after the signal handler has returned)
320 returns immediately (with return value \-1 and
327 .BR F_GETLK " (\fIstruct flock *\fP)"
328 On input to this call,
330 describes a lock we would like to place on the file.
331 If the lock could be placed,
333 does not actually place it, but returns
339 and leaves the other fields of the structure unchanged.
340 If one or more incompatible locks would prevent
341 this lock being placed, then
343 returns details about one of these locks in the
344 .IR l_type ", " l_whence ", " l_start ", and " l_len
349 to be the PID of the process holding that lock.
351 In order to place a read lock,
353 must be open for reading.
354 In order to place a write lock,
356 must be open for writing.
357 To place both types of lock, open a file read-write.
359 As well as being removed by an explicit
361 record locks are automatically released when the process
362 terminates or if it closes
364 file descriptor referring to a file on which locks are held.
365 .\" (Additional file descriptors referring to the same file
366 .\" may have been obtained by calls to
367 .\" .BR open "(2), " dup "(2), " dup2 "(2), or " fcntl ().)
368 This is bad: it means that a process can lose the locks on
373 when for some reason a library function decides to open, read
376 Record locks are not inherited by a child created via
378 but are preserved across an
381 Because of the buffering performed by the
383 library, the use of record locking with routines in that package
384 should be avoided; use
389 .SS "Mandatory locking"
391 The above record locks may be either advisory or mandatory,
392 and are advisory by default.
394 Advisory locks are not enforced and are useful only between
395 cooperating processes.
397 Mandatory locks are enforced for all processes.
398 If a process tries to perform an incompatible access (e.g.,
402 on a file region that has an incompatible mandatory lock,
403 then the result depends upon whether the
405 flag is enabled for its open file description.
408 flag is not enabled, then
409 system call is blocked until the lock is removed
410 or converted to a mode that is compatible with the access.
413 flag is enabled, then the system call fails with the error
416 To make use of mandatory locks, mandatory locking must be enabled
417 both on the file system that contains the file to be locked,
418 and on the file itself.
419 Mandatory locking is enabled on a file system
420 using the "\-o mand" option to
426 Mandatory locking is enabled on a file by disabling
427 group execute permission on the file and enabling the set-group-ID
433 The Linux implementation of mandatory locking is unreliable.
435 .SS "Managing signals"
443 are used to manage I/O availability signals:
445 .BR F_GETOWN " (\fIvoid\fP)"
446 Return (as the function result)
447 the process ID or process group currently receiving
451 signals for events on file descriptor
453 Process IDs are returned as positive values;
454 process group IDs are returned as negative values (but see BUGS below).
458 .BR F_SETOWN " (\fIlong\fP)"
459 Set the process ID or process group ID that will receive
463 signals for events on file descriptor
467 A process ID is specified as a positive value;
468 a process group ID is specified as a negative value.
469 Most commonly, the calling process specifies itself as the owner
478 status flag on a file descriptor by using the
484 signal is sent whenever input or output becomes possible
485 on that file descriptor.
487 can be used to obtain delivery of a signal other than
489 If this permission check fails, then the signal is
492 Sending a signal to the owner process (group) specified by
494 is subject to the same permissions checks as are described for
496 where the sending process is the one that employs
498 (but see BUGS below).
500 If the file descriptor
507 signals that are delivered when out-of-band
508 data arrives on that socket.
510 is sent in any situation where
512 would report the socket as having an "exceptional condition".)
513 .\" The following appears to be rubbish. It doesn't seem to
514 .\" be true according to the kernel source, and I can write
515 .\" a program that gets a terminal-generated SIGIO even though
516 .\" it is not the foreground process group of the terminal.
519 .\" If the file descriptor
521 .\" refers to a terminal device, then SIGIO
522 .\" signals are sent to the foreground process group of the terminal.
524 The following was true in 2.6.x kernels up to and including
528 If a nonzero value is given to
530 in a multithreaded process running with a threading library
531 that supports thread groups (e.g., NPTL),
532 then a positive value given to
534 has a different meaning:
535 .\" The relevant place in the (2.6) kernel source is the
536 .\" 'switch' in fs/fcntl.c::send_sigio_to_task() -- MTK, Apr 2005
537 instead of being a process ID identifying a whole process,
538 it is a thread ID identifying a specific thread within a process.
539 Consequently, it may be necessary to pass
545 to get sensible results when
548 (In current Linux threading implementations,
549 a main thread's thread ID is the same as its process ID.
550 This means that a single-threaded program can equally use
555 Note, however, that the statements in this paragraph do not apply
558 signal generated for out-of-band data on a socket:
559 this signal is always sent to either a process or a process group,
560 depending on the value given to
562 .\" send_sigurg()/send_sigurg_to_task() bypasses
563 .\" kill_fasync()/send_sigio()/send_sigio_to_task()
564 .\" to directly call send_group_sig_info()
565 .\" -- MTK, Apr 2005 (kernel 2.6.11)
568 The above behavior was accidentally dropped in Linux 2.6.12,
569 and won't be restored.
570 From Linux 2.6.32 onward, use
576 signals at a particular thread.
578 .BR F_GETOWN_EX " (struct f_owner_ex *) (since Linux 2.6.32)"
579 Return the current file descriptor owner settings
580 as defined by a previous
583 The information is returned in the structure pointed to by
585 which has the following form:
598 field will have one of the values
605 field is a positive integer representing a thread ID, process ID,
611 .BR F_SETOWN_EX " (struct f_owner_ex *) (since Linux 2.6.32)"
612 This operation performs a similar task to
614 It allows the caller to direct I/O availability signals
615 to a specific thread, process, or process group.
616 The caller specifies the target of signals via
618 which is a pointer to a
623 field has one of the following values, which define how
629 Send the signal to the thread whose thread ID
630 (the value returned by a call to
638 Send the signal to the process whose ID
643 Send the signal to the process group whose ID
646 (Note that, unlike with
648 a process group ID is specified as a positive value here.)
651 .BR F_GETSIG " (\fIvoid\fP)"
652 Return (as the function result)
653 the signal sent when input or output becomes possible.
654 A value of zero means
657 Any other value (including
660 signal sent instead, and in this case additional info is available to
661 the signal handler if installed with
666 .BR F_SETSIG " (\fIlong\fP)"
667 Set the signal sent when input or output becomes possible
668 to the value given in
670 A value of zero means to send the default
673 Any other value (including
675 is the signal to send instead, and in this case additional info
676 is available to the signal handler if installed with
679 .\" The following was true only up until 2.6.11:
681 .\" Additionally, passing a nonzero value to
683 .\" changes the signal recipient from a whole process to a specific thread
684 .\" within a process.
685 .\" See the description of
687 .\" for more details.
691 with a nonzero value, and setting
696 extra information about I/O events is passed to
702 field indicates the source is
706 field gives the file descriptor associated with the event.
708 there is no indication which file descriptors are pending, and you
709 should use the usual mechanisms
715 set etc.) to determine which file descriptors are available for I/O.
717 By selecting a real time signal (value >=
719 multiple I/O events may be queued using the same signal numbers.
720 (Queuing is dependent on available memory).
721 Extra information is available
724 is set for the signal handler, as above.
726 Note that Linux imposes a limit on the
727 number of real-time signals that may be queued to a
732 and if this limit is reached, then the kernel reverts to
735 and this signal is delivered to the entire
736 process rather than to a specific thread.
737 .\" See fs/fcntl.c::send_sigio_to_task() (2.4/2.6) sources -- MTK, Apr 05
739 Using these mechanisms, a program can implement fully asynchronous I/O
750 is specific to BSD and Linux.
757 POSIX has asynchronous I/O and the
759 structure to achieve similar things; these are also available
760 in Linux as part of the GNU C Library (Glibc).
765 (Linux 2.4 onward) are used (respectively) to establish a new lease,
766 and retrieve the current lease, on the open file description
767 referred to by the file descriptor
769 A file lease provides a mechanism whereby the process holding
770 the lease (the "lease holder") is notified (via delivery of a signal)
771 when a process (the "lease breaker") tries to
775 the file referred to by that file descriptor.
777 .BR F_SETLEASE " (\fIlong\fP)"
778 Set or remove a file lease according to which of the following
779 values is specified in the integer
784 Take out a read lease.
785 This will cause the calling process to be notified when
786 the file is opened for writing or is truncated.
787 .\" The following became true in kernel 2.6.10:
788 .\" See the man-pages-2.09 Changelog for further info.
789 A read lease can only be placed on a file descriptor that
793 Take out a write lease.
794 This will cause the caller to be notified when
795 the file is opened for reading or writing or is truncated.
796 A write lease may be placed on a file only if there are no
797 other open file descriptors for the file.
800 Remove our lease from the file.
803 Leases are associated with an open file description (see
805 This means that duplicate file descriptors (created by, for example,
809 refer to the same lease, and this lease may be modified
810 or released using any of these descriptors.
811 Furthermore, the lease is released by either an explicit
813 operation on any of these duplicate descriptors, or when all
814 such descriptors have been closed.
816 Leases may only be taken out on regular files.
817 An unprivileged process may only take out a lease on a file whose
818 UID (owner) matches the file system UID of the process.
821 capability may take out leases on arbitrary files.
823 .BR F_GETLEASE " (\fIvoid\fP)"
824 Indicates what type of lease is associated with the file descriptor
827 .BR F_RDLCK ", " F_WRLCK ", or " F_UNLCK ,
828 indicating, respectively, a read lease , a write lease, or no lease.
832 When a process (the "lease breaker") performs an
836 that conflicts with a lease established via
838 the system call is blocked by the kernel and
839 the kernel notifies the lease holder by sending it a signal
842 The lease holder should respond to receipt of this signal by doing
843 whatever cleanup is required in preparation for the file to be
844 accessed by another process (e.g., flushing cached buffers) and
845 then either remove or downgrade its lease.
846 A lease is removed by performing an
852 If the lease holder currently holds a write lease on the file,
853 and the lease breaker is opening the file for reading,
854 then it is sufficient for the lease holder to downgrade
855 the lease to a read lease.
856 This is done by performing an
863 If the lease holder fails to downgrade or remove the lease within
864 the number of seconds specified in
865 .I /proc/sys/fs/lease-break-time
866 then the kernel forcibly removes or downgrades the lease holder's lease.
868 Once the lease has been voluntarily or forcibly removed or downgraded,
869 and assuming the lease breaker has not unblocked its system call,
870 the kernel permits the lease breaker's system call to proceed.
872 If the lease breaker's blocked
876 is interrupted by a signal handler,
877 then the system call fails with the error
879 but the other steps still occur as described above.
880 If the lease breaker is killed by a signal while blocked in
884 then the other steps still occur as described above.
885 If the lease breaker specifies the
889 then the call immediately fails with the error
891 but the other steps still occur as described above.
893 The default signal used to notify the lease holder is
895 but this can be changed using the
901 command is performed (even one specifying
904 handler is established using
906 then the handler will receive a
908 structure as its second argument, and the
910 field of this argument will hold the descriptor of the leased file
911 that has been accessed by another process.
912 (This is useful if the caller holds leases against multiple files).
913 .SS "File and directory change notification (dnotify)"
915 .BR F_NOTIFY " (\fIlong\fP)"
917 Provide notification when the directory referred to by
919 or any of the files that it contains is changed.
920 The events to be notified are specified in
922 which is a bit mask specified by ORing together zero or more of
929 A file was accessed (read, pread, readv)
932 A file was modified (write, pwrite, writev, truncate, ftruncate).
935 A file was created (open, creat, mknod, mkdir, link, symlink, rename).
938 A file was unlinked (unlink, rename to another directory, rmdir).
941 A file was renamed within this directory (rename).
944 The attributes of a file were changed (chown, chmod, utime[s]).
948 (In order to obtain these definitions, the
950 feature test macro must be defined before including
954 Directory notifications are normally "one-shot", and the application
955 must reregister to receive further notifications.
960 then notification will remain in effect until explicitly removed.
962 .\" The following does seem a poor API-design choice...
965 requests is cumulative, with the events in
967 being added to the set already monitored.
968 To disable notification of all events, make an
974 Notification occurs via delivery of a signal.
975 The default signal is
977 but this can be changed using the
981 In the latter case, the signal handler receives a
983 structure as its second argument (if the handler was
988 field of this structure contains the file descriptor which
989 generated the notification (useful when establishing notification
990 on multiple directories).
992 Especially when using
994 a real time signal should be used for notification,
995 so that multiple notifications can be queued.
998 New applications should use the
1000 interface (available since kernel 2.6.13),
1001 which provides a much superior interface for obtaining notifications of
1005 .SS "Changing the capacity of a pipe"
1007 .BR F_SETPIPE_SZ " (\fIlong\fP; since Linux 2.6.35)"
1008 Change the capacity of the pipe referred to by
1013 An unprivileged process can adjust the pipe capacity to any value
1014 between the system page size and the limit defined in
1015 .IR /proc/sys/fs/pipe-size-max
1018 Attempts to set the pipe capacity below the page size are silently
1019 rounded up to the page size.
1020 Attempts by an unprivileged process to set the pipe capacity above the limit in
1021 .IR /proc/sys/fs/pipe-size-max
1024 a privileged process
1025 .RB ( CAP_SYS_RESOURCE )
1026 can override the limit.
1027 When allocating the buffer for the pipe,
1028 the kernel may use a capacity larger than
1030 if that is convenient for the implementation.
1033 operation returns the actual size used.
1034 Attempting to set the pipe capacity smaller than the amount
1035 of buffer space currently used to store data produces the error
1038 .BR F_GETPIPE_SZ " (\fIvoid\fP; since Linux 2.6.35)"
1039 Return (as the function result) the capacity of the pipe referred to by
1042 For a successful call, the return value depends on the operation:
1048 Value of file descriptor flags.
1051 Value of file status flags.
1054 Type of lease held on file descriptor.
1057 Value of descriptor owner.
1060 Value of signal sent when read or write becomes possible, or zero
1071 On error, \-1 is returned, and
1073 is set appropriately.
1076 .BR EACCES " or " EAGAIN
1077 Operation is prohibited by locks held by other processes.
1080 The operation is prohibited because the file has been memory-mapped by
1085 is not an open file descriptor, or the command was
1089 and the file descriptor open mode doesn't match with the
1090 type of lock requested.
1093 It was detected that the specified
1095 command would cause a deadlock.
1099 is outside your accessible address space.
1104 the command was interrupted by a signal; see
1107 .BR F_GETLK " and " F_SETLK ,
1108 the command was interrupted by a signal before the lock was checked or
1110 Most likely when locking a remote file (e.g., locking over
1111 NFS), but can sometimes happen locally.
1117 is negative or is greater than the maximum allowable value.
1121 is not an allowable signal number.
1126 the process already has the maximum number of file descriptors open.
1129 Too many segment locks open, lock table is full, or a remote locking
1130 protocol failed (e.g., locking over NFS).
1133 Attempted to clear the
1135 flag on a file that has the append-only attribute set.
1137 SVr4, 4.3BSD, POSIX.1-2001.
1148 are specified in POSIX.1-2001.
1153 are specified in POSIX.1-2001.
1154 (To get their definitions, define
1158 with the value 500 or greater, or define
1160 with the value 200809L or greater.)
1163 is specified in POSIX.1-2008.
1164 (To get this definition, define
1166 with the value 200809L or greater, or
1168 with the value 700 or greater.)
1183 macro to obtain these definitions.)
1185 .\" SVr4 documents additional EIO, ENOLINK and EOVERFLOW error conditions.
1189 system call was not designed to handle large file offsets
1195 system call was added in Linux 2.4.
1196 The newer system call employs a different structure for file locking,
1198 and corresponding commands,
1203 However, these details can be ignored by applications using glibc, whose
1205 wrapper function transparently employs the more recent system call
1206 where it is available.
1208 The errors returned by
1210 are different from those returned by
1213 Since kernel 2.0, there is no interaction between the types of lock
1219 Several systems have more fields in
1221 such as, for example,
1223 .\" e.g., Solaris 8 documents this field in fcntl(2), and Irix 6.5
1224 .\" documents it in fcntl(5). mtk, May 2007
1227 alone is not going to be very useful if the process holding the lock
1228 may live on a different machine.
1230 A limitation of the Linux system call conventions on some
1231 architectures (notably i386) means that if a (negative)
1232 process group ID to be returned by
1234 falls in the range \-1 to \-4095, then the return value is wrongly
1235 interpreted by glibc as an error in the system call;
1236 .\" glibc source: sysdeps/unix/sysv/linux/i386/sysdep.h
1237 that is, the return value of
1241 will contain the (positive) process group ID.
1244 operation avoids this problem.
1245 .\" mtk, Dec 04: some limited testing on alpha and ia64 seems to
1246 .\" indicate that ANY negative PGID value will cause F_GETOWN
1247 .\" to misinterpret the return as an error. Some other architectures
1248 .\" seem to have the same range check as i386.
1249 Since glibc version 2.11, glibc makes the kernel
1251 problem invisible by implementing
1256 In Linux 2.4 and earlier, there is bug that can occur
1257 when an unprivileged process uses
1259 to specify the owner
1260 of a socket file descriptor
1261 as a process (group) other than the caller.
1268 even when the owner process (group) is one that the caller
1269 has permission to send signals to.
1270 Despite this error return, the file descriptor owner is set,
1271 and signals will be sent to the owner.
1273 The implementation of mandatory locking in all known versions of Linux
1274 is subject to race conditions which render it unreliable:
1275 .\" http://marc.info/?l=linux-kernel&m=119013491707153&w=2
1278 call that overlaps with a lock may modify data after the mandatory lock is
1282 call that overlaps with a lock may detect changes to data that were made
1283 only after a write lock was acquired.
1284 Similar races exist between mandatory locks and
1286 It is therefore inadvisable to rely on mandatory locking.
1293 .BR capabilities (7),
1294 .BR feature_test_macros (7)
1298 .IR mandatory-locking.txt ,
1301 in the kernel source directory
1302 .IR Documentation/filesystems/ .
1303 (On older kernels, these files are directly under the
1306 .I mandatory-locking.txt
1308 .IR mandatory.txt .)