]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man/man2/fcntl.2
man/, share/mk/: Move man*/ to man/
[thirdparty/man-pages.git] / man / man2 / fcntl.2
CommitLineData
fea681da 1.\" This manpage is Copyright (C) 1992 Drew Eckhardt;
99b5ab79
MK
2.\" and Copyright (C) 1993 Michael Haardt, Ian Jackson;
3.\" and Copyright (C) 1998 Jamie Lokier;
4.\" and Copyright (C) 2002-2010, 2014 Michael Kerrisk;
5.\" and Copyright (C) 2014 Jeff Layton
6bdad35b 6.\" and Copyright (C) 2014 David Herrmann
580082a1 7.\" and Copyright (C) 2017 Jens Axboe
fea681da 8.\"
5fbde956 9.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
10.\"
11.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
12.\" Modified 1995-09-26 by Andries Brouwer <aeb@cwi.nl>
13.\" and again on 960413 and 980804 and 981223.
14.\" Modified 1998-12-11 by Jamie Lokier <jamie@imbolc.ucc.ie>
15.\" Applied correction by Christian Ehrhardt - aeb, 990712
c11b1abf 16.\" Modified 2002-04-23 by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da
MK
17.\" Added note on F_SETFL and O_DIRECT
18.\" Complete rewrite + expansion of material on file locking
19.\" Incorporated description of F_NOTIFY, drawing on
20.\" Stephen Rothwell's notes in Documentation/dnotify.txt.
21.\" Added description of F_SETLEASE and F_GETLEASE
22.\" Corrected and polished, aeb, 020527.
c11b1abf 23.\" Modified 2004-03-03 by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da
MK
24.\" Modified description of file leases: fixed some errors of detail
25.\" Replaced the term "lease contestant" by "lease breaker"
c11b1abf 26.\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 27.\" Added notes on capability requirements
1c1e15ed 28.\" Modified 2004-12-08, added O_NOATIME after note from Martin Pool
c13182ef 29.\" 2004-12-10, mtk, noted F_GETOWN bug after suggestion from aeb.
2f36a807 30.\" 2005-04-08 Jamie Lokier <jamie@shareable.org>, mtk
d9bfdb9c 31.\" Described behavior of F_SETOWN/F_SETSIG in
71fea607 32.\" multithreaded processes, and generally cleaned
2f36a807 33.\" up the discussion of F_SETOWN.
c13182ef 34.\" 2005-05-20, Johannes Nicolai <johannes.nicolai@hpi.uni-potsdam.de>,
9d2a7b1f
MK
35.\" mtk: Noted F_SETOWN bug for socket file descriptor in Linux 2.4
36.\" and earlier. Added text on permissions required to send signal.
dd164bfc
MK
37.\" 2009-09-30, Michael Kerrisk
38.\" Note obsolete F_SETOWN behavior with threads.
39.\" Document F_SETOWN_EX and F_GETOWN_EX
14f7d1a4
MK
40.\" 2010-06-17, Michael Kerrisk
41.\" Document F_SETPIPE_SZ and F_GETPIPE_SZ.
a25d701d 42.\" 2014-07-08, David Herrmann <dh.herrmann@gmail.com>
6bdad35b 43.\" Document F_ADD_SEALS and F_GET_SEALS
580082a1
JA
44.\" 2017-06-26, Jens Axboe <axboe@kernel.dk>
45.\" Document F_{GET,SET}_RW_HINT and F_{GET,SET}_FILE_RW_HINT
fea681da 46.\"
4c1c5274 47.TH fcntl 2 (date) "Linux man-pages (unreleased)"
fea681da
MK
48.SH NAME
49fcntl \- manipulate file descriptor
ba96f40e
AC
50.SH LIBRARY
51Standard C library
8fc3b2cf 52.RI ( libc ", " \-lc )
fea681da
MK
53.SH SYNOPSIS
54.nf
fea681da 55.B #include <fcntl.h>
c6d039a3 56.P
980ac57d 57.BI "int fcntl(int " fd ", int " op ", ... /* " arg " */ );"
fea681da
MK
58.fi
59.SH DESCRIPTION
cff88e99
MK
60.BR fcntl ()
61performs one of the operations described below on the open file descriptor
fea681da 62.IR fd .
cff88e99 63The operation is determined by
980ac57d 64.IR op .
c6d039a3 65.P
68e0696a
MK
66.BR fcntl ()
67can take an optional third argument.
68Whether or not this argument is required is determined by
980ac57d 69.IR op .
63a6efda 70The required argument type is indicated in parentheses after each
980ac57d 71.I op
68e0696a 72name (in most cases, the required type is
ed9821bb 73.IR int ,
68e0696a
MK
74and we identify the argument using the name
75.IR arg ),
76or
77.I void
78is specified if the argument is not required.
c6d039a3 79.P
6024e733
MK
80Certain of the operations below are supported only since a particular
81Linux kernel version.
82The preferred method of checking whether the host kernel supports
83a particular operation is to invoke
84.BR fcntl ()
85with the desired
980ac57d 86.I op
6024e733
MK
87value and then test whether the call failed with
88.BR EINVAL ,
89indicating that the kernel does not recognize this value.
73d8cece 90.SS Duplicating a file descriptor
fea681da 91.TP
ed9821bb 92.BR F_DUPFD " (\fIint\fP)"
6a459f6f 93Duplicate the file descriptor
1ae6b2c7 94.I fd
6a459f6f
MK
95using the lowest-numbered available file descriptor greater than or equal to
96.IR arg .
cff88e99 97This is different from
68e0696a 98.BR dup2 (2),
d9cb0d7d 99which uses exactly the file descriptor specified.
ca92ce95 100.IP
d9cb0d7d 101On success, the new file descriptor is returned.
ca92ce95 102.IP
cff88e99
MK
103See
104.BR dup (2)
105for further details.
ef203e45 106.TP
ed9821bb 107.BR F_DUPFD_CLOEXEC " (\fIint\fP; since Linux 2.6.24)"
635d3959 108As for
ef203e45
MK
109.BR F_DUPFD ,
110but additionally set the
d9cb0d7d 111close-on-exec flag for the duplicate file descriptor.
ef203e45 112Specifying this flag permits a program to avoid an additional
0e92e8cc 113.BR fcntl ()
ef203e45
MK
114.B F_SETFD
115operation to set the
116.B FD_CLOEXEC
117flag.
118For an explanation of why this flag is useful,
e4b4caa6 119see the description of
ef203e45
MK
120.B O_CLOEXEC
121in
122.BR open (2).
73d8cece 123.SS File descriptor flags
980ac57d 124The following operations manipulate the flags associated with
c13182ef 125a file descriptor.
cff88e99
MK
126Currently, only one such flag is defined:
127.BR FD_CLOEXEC ,
128the close-on-exec flag.
129If the
fea681da 130.B FD_CLOEXEC
8b4be846
MK
131bit is set,
132the file descriptor will automatically be closed during a successful
133.BR execve (2).
134(If the
135.BR execve (2)
136fails, the file descriptor is left open.)
137If the
138.B FD_CLOEXEC
139bit is not set, the file descriptor will remain open across an
140.BR execve (2).
fea681da 141.TP
68e0696a 142.BR F_GETFD " (\fIvoid\fP)"
f157f403 143Return (as the function result) the file descriptor flags;
68e0696a
MK
144.I arg
145is ignored.
cff88e99 146.TP
ed9821bb 147.BR F_SETFD " (\fIint\fP)"
cff88e99 148Set the file descriptor flags to the value specified by
fea681da 149.IR arg .
c6d039a3 150.P
2f4772d2
MK
151In multithreaded programs, using
152.BR fcntl ()
153.B F_SETFD
154to set the close-on-exec flag at the same time as another thread performs a
155.BR fork (2)
156plus
157.BR execve (2)
158is vulnerable to a race condition that may unintentionally leak
159the file descriptor to the program executed in the child process.
160See the discussion of the
1ae6b2c7 161.B O_CLOEXEC
2f4772d2
MK
162flag in
163.BR open (2)
164for details and a remedy to the problem.
73d8cece 165.SS File status flags
08478724
MK
166Each open file description has certain associated status flags,
167initialized by
fea681da
MK
168.BR open (2)
169.\" or
170.\" .BR creat (2),
171and possibly modified by
2777b1ca 172.BR fcntl ().
c13182ef 173Duplicated file descriptors
cff88e99 174(made with
0bfa087b 175.BR dup (2),
cff88e99 176.BR fcntl (F_DUPFD),
0bfa087b 177.BR fork (2),
cff88e99
MK
178etc.) refer to the same open file description, and thus
179share the same file status flags.
c6d039a3 180.P
cff88e99 181The file status flags and their semantics are described in
fea681da
MK
182.BR open (2).
183.TP
68e0696a 184.BR F_GETFL " (\fIvoid\fP)"
f157f403
MK
185Return (as the function result)
186the file access mode and the file status flags;
68e0696a
MK
187.I arg
188is ignored.
fea681da 189.TP
ed9821bb 190.BR F_SETFL " (\fIint\fP)"
cff88e99 191Set the file status flags to the value specified by
fea681da 192.IR arg .
c13182ef 193File access mode
cff88e99
MK
194.RB ( O_RDONLY ", " O_WRONLY ", " O_RDWR )
195and file creation flags
68b93ce2
MK
196(i.e.,
197.BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", " O_TRUNC )
cff88e99 198in
fea681da
MK
199.I arg
200are ignored.
980ac57d 201On Linux, this operation can change only the
c13182ef 202.BR O_APPEND ,
1c1e15ed
MK
203.BR O_ASYNC ,
204.BR O_DIRECT ,
205.BR O_NOATIME ,
c13182ef 206and
0daa9e92 207.B O_NONBLOCK
1c1e15ed 208flags.
639b33d7 209It is not possible to change the
1ae6b2c7 210.B O_DSYNC
639b33d7 211and
1ae6b2c7 212.B O_SYNC
639b33d7 213flags; see BUGS, below.
9584daf7 214.SS Advisory record locking
7562b10e
MK
215Linux implements traditional ("process-associated") UNIX record locks,
216as standardized by POSIX.
217For a Linux-specific alternative with better semantics,
218see the discussion of open file description locks below.
c6d039a3 219.P
dc45cae3
MK
220.BR F_SETLK ,
221.BR F_SETLKW ,
222and
1ae6b2c7 223.B F_GETLK
fea681da 224are used to acquire, release, and test for the existence of record
9584daf7 225locks (also known as byte-range, file-segment, or file-region locks).
68e0696a
MK
226The third argument,
227.IR lock ,
fea681da
MK
228is a pointer to a structure that has at least the following fields
229(in unspecified order).
c6d039a3 230.P
088a639b 231.in +4n
778ac627 232.EX
fea681da
MK
233struct flock {
234 ...
235 short l_type; /* Type of lock: F_RDLCK,
236 F_WRLCK, F_UNLCK */
237 short l_whence; /* How to interpret l_start:
238 SEEK_SET, SEEK_CUR, SEEK_END */
239 off_t l_start; /* Starting offset for lock */
240 off_t l_len; /* Number of bytes to lock */
241 pid_t l_pid; /* PID of process blocking our lock
99b5ab79 242 (set by F_GETLK and F_OFD_GETLK) */
fea681da
MK
243 ...
244};
778ac627 245.EE
088a639b 246.in
c6d039a3 247.P
fea681da
MK
248The
249.IR l_whence ", " l_start ", and " l_len
250fields of this structure specify the range of bytes we wish to lock.
057dce78
MK
251Bytes past the end of the file may be locked,
252but not bytes before the start of the file.
c6d039a3 253.P
fea681da
MK
254.I l_start
255is the starting offset for the lock, and is interpreted
256relative to either:
257the start of the file (if
258.I l_whence
259is
260.BR SEEK_SET );
261the current file offset (if
262.I l_whence
263is
264.BR SEEK_CUR );
265or the end of the file (if
266.I l_whence
267is
268.BR SEEK_END ).
269In the final two cases,
270.I l_start
271can be a negative number provided the
272offset does not lie before the start of the file.
c6d039a3 273.P
fea681da 274.I l_len
057dce78
MK
275specifies the number of bytes to be locked.
276If
277.I l_len
278is positive, then the range to be locked covers bytes
279.I l_start
280up to and including
95dadb39 281.IR l_start + l_len \-1.
fea681da
MK
282Specifying 0 for
283.I l_len
284has the special meaning: lock all bytes starting at the
285location specified by
286.IR l_whence " and " l_start
287through to the end of file, no matter how large the file grows.
c6d039a3 288.P
057dce78
MK
289POSIX.1-2001 allows (but does not require)
290an implementation to support a negative
291.I l_len
292value; if
293.I l_len
294is negative, the interval described by
295.I lock
296covers bytes
297.IR l_start + l_len
298up to and including
299.IR l_start \-1.
b324e17d 300This is supported since Linux 2.4.21 and Linux 2.5.49.
c6d039a3 301.P
fea681da
MK
302The
303.I l_type
304field can be used to place a read
305.RB ( F_RDLCK )
306or a write
1c287bbf 307.RB ( F_WRLCK )
fea681da
MK
308lock on a file.
309Any number of processes may hold a read lock (shared lock)
310on a file region, but only one process may hold a write lock
7c93fec0
MK
311(exclusive lock).
312An exclusive lock excludes all other locks,
fea681da
MK
313both shared and exclusive.
314A single process can hold only one type of lock on a file region;
315if a new lock is applied to an already-locked region,
8c450534 316then the existing lock is converted to the new lock type.
fea681da
MK
317(Such conversions may involve splitting, shrinking, or coalescing with
318an existing lock if the byte range specified by the new lock does not
319precisely coincide with the range of the existing lock.)
320.TP
68e0696a 321.BR F_SETLK " (\fIstruct flock *\fP)"
fea681da
MK
322Acquire a lock (when
323.I l_type
324is
325.B F_RDLCK
326or
327.BR F_WRLCK )
328or release a lock (when
329.I l_type
330is
331.BR F_UNLCK )
332on the bytes specified by the
333.IR l_whence ", " l_start ", and " l_len
334fields of
335.IR lock .
336If a conflicting lock is held by another process,
337this call returns \-1 and sets
338.I errno
339to
340.B EACCES
341or
342.BR EAGAIN .
d068eb3b
MK
343(The error returned in this case differs across implementations,
344so POSIX requires a portable application to check for both errors.)
fea681da 345.TP
68e0696a 346.BR F_SETLKW " (\fIstruct flock *\fP)"
fea681da
MK
347As for
348.BR F_SETLK ,
349but if a conflicting lock is held on the file, then wait for that
350lock to be released.
351If a signal is caught while waiting, then the call is interrupted
352and (after the signal handler has returned)
353returns immediately (with return value \-1 and
354.I errno
355set to
01538d0d
MK
356.BR EINTR ;
357see
358.BR signal (7)).
fea681da 359.TP
68e0696a 360.BR F_GETLK " (\fIstruct flock *\fP)"
fea681da
MK
361On input to this call,
362.I lock
363describes a lock we would like to place on the file.
364If the lock could be placed,
365.BR fcntl ()
366does not actually place it, but returns
367.B F_UNLCK
368in the
369.I l_type
370field of
371.I lock
372and leaves the other fields of the structure unchanged.
778ac627 373.IP
fea681da
MK
374If one or more incompatible locks would prevent
375this lock being placed, then
376.BR fcntl ()
99b5ab79 377returns details about one of those locks in the
fea681da
MK
378.IR l_type ", " l_whence ", " l_start ", and " l_len
379fields of
99b5ab79
MK
380.IR lock .
381If the conflicting lock is a traditional (process-associated) record lock,
382then the
fea681da 383.I l_pid
99b5ab79
MK
384field is set to the PID of the process holding that lock.
385If the conflicting lock is an open file description lock, then
2d3e4b83 386.I l_pid
99b5ab79
MK
387is set to \-1.
388Note that the returned information
eceaee47 389may already be out of date by the time the caller inspects it.
c6d039a3 390.P
fea681da
MK
391In order to place a read lock,
392.I fd
393must be open for reading.
394In order to place a write lock,
395.I fd
396must be open for writing.
397To place both types of lock, open a file read-write.
c6d039a3 398.P
76868835
MK
399When placing locks with
400.BR F_SETLKW ,
401the kernel detects
402.IR deadlocks ,
403whereby two or more processes have their
404lock requests mutually blocked by locks held by the other processes.
405For example, suppose process A holds a write lock on byte 100 of a file,
406and process B holds a write lock on byte 200.
407If each process then attempts to lock the byte already
408locked by the other process using
409.BR F_SETLKW ,
410then, without deadlock detection,
411both processes would remain blocked indefinitely.
412When the kernel detects such deadlocks,
413it causes one of the blocking lock requests to immediately fail with the error
414.BR EDEADLK ;
415an application that encounters such an error should release
416some of its locks to allow other applications to proceed before
417attempting regain the locks that it requires.
418Circular deadlocks involving more than two processes are also detected.
419Note, however, that there are limitations to the kernel's
420deadlock-detection algorithm; see BUGS.
c6d039a3 421.P
fea681da
MK
422As well as being removed by an explicit
423.BR F_UNLCK ,
1a93af04 424record locks are automatically released when the process terminates.
c6d039a3 425.P
fea681da
MK
426Record locks are not inherited by a child created via
427.BR fork (2),
428but are preserved across an
429.BR execve (2).
c6d039a3 430.P
fea681da
MK
431Because of the buffering performed by the
432.BR stdio (3)
433library, the use of record locking with routines in that package
434should be avoided; use
35e21ba7 435.BR read (2)
c13182ef 436and
35e21ba7 437.BR write (2)
fea681da 438instead.
c6d039a3 439.P
1a93af04
MK
440The record locks described above are associated with the process
441(unlike the open file description locks described below).
442This has some unfortunate consequences:
cdede5cd 443.IP \[bu] 3
d9312ec7 444If a process closes
1a93af04 445.I any
d9312ec7
MK
446file descriptor referring to a file,
447then all of the process's locks on that file are released,
448regardless of the file descriptor(s) on which the locks were obtained.
1a93af04
MK
449.\" (Additional file descriptors referring to the same file
450.\" may have been obtained by calls to
451.\" .BR open "(2), " dup "(2), " dup2 "(2), or " fcntl ().)
452This is bad: it means that a process can lose its locks on
453a file such as
454.I /etc/passwd
455or
456.I /etc/mtab
457when for some reason a library function decides to open, read,
458and close the same file.
cdede5cd 459.IP \[bu]
1a93af04
MK
460The threads in a process share locks.
461In other words,
462a multithreaded program can't use record locking to ensure
97e03523 463that threads don't simultaneously access the same region of a file.
c6d039a3 464.P
1a93af04 465Open file description locks solve both of these problems.
2d3e4b83 466.SS Open file description locks (non-POSIX)
bfb14716
MK
467Open file description locks are advisory byte-range locks whose operation is
468in most respects identical to the traditional record locks described above.
469This lock type is Linux-specific,
38702b6c 470and available since Linux 3.15.
728aff57
MK
471(There is a proposal with the Austin Group
472.\" FIXME . Review progress into POSIX
473.\" http://austingroupbugs.net/view.php?id=768
474to include this lock type in the next revision of POSIX.1.)
64515702 475For an explanation of open file descriptions, see
b7a3dc84 476.BR open (2).
c6d039a3 477.P
99b5ab79
MK
478The principal difference between the two lock types
479is that whereas traditional record locks
480are associated with a process,
481open file description locks are associated with the
482open file description on which they are acquired,
483much like locks acquired with
484.BR flock (2).
485Consequently (and unlike traditional advisory record locks),
486open file description locks are inherited across
2d3e4b83 487.BR fork (2)
99b5ab79 488(and
2d3e4b83
JL
489.BR clone (2)
490with
99b5ab79
MK
491.BR CLONE_FILES ),
492and are only automatically released on the last close
493of the open file description,
494instead of being released on any close of the file.
c6d039a3 495.P
ee662773
MK
496Conflicting lock combinations
497(i.e., a read lock and a write lock or two write locks)
498where one lock is an open file description lock and the other
499is a traditional record lock conflict
2d3e4b83 500even when they are acquired by the same process on the same file descriptor.
c6d039a3 501.P
97e03523
MK
502Open file description locks placed via the same open file description
503(i.e., via the same file descriptor,
504or via a duplicate of the file descriptor created by
505.BR fork (2),
506.BR dup (2),
bf7bc8b8 507.BR fcntl ()
97e03523
MK
508.BR F_DUPFD ,
509and so on) are always compatible:
510if a new lock is placed on an already locked region,
511then the existing lock is converted to the new lock type.
512(Such conversions may result in splitting, shrinking, or coalescing with
513an existing lock as discussed above.)
c6d039a3 514.P
97e03523
MK
515On the other hand, open file description locks may conflict with
516each other when they are acquired via different open file descriptions.
517Thus, the threads in a multithreaded program can use
518open file description locks to synchronize access to a file region
519by having each thread perform its own
520.BR open (2)
521on the file and applying locks via the resulting file descriptor.
c6d039a3 522.P
99b5ab79
MK
523As with traditional advisory locks, the third argument to
524.BR fcntl (),
525.IR lock ,
526is a pointer to an
1ae6b2c7 527.I flock
99b5ab79
MK
528structure.
529By contrast with traditional record locks, the
2d3e4b83 530.I l_pid
99b5ab79 531field of that structure must be set to zero
980ac57d 532when using the operations described below.
c6d039a3 533.P
980ac57d 534The operations for working with open file description locks are analogous
99b5ab79 535to those used with traditional locks:
2d3e4b83
JL
536.TP
537.BR F_OFD_SETLK " (\fIstruct flock *\fP)"
538Acquire an open file description lock (when
539.I l_type
540is
541.B F_RDLCK
542or
543.BR F_WRLCK )
544or release an open file description lock (when
545.I l_type
546is
547.BR F_UNLCK )
548on the bytes specified by the
549.IR l_whence ", " l_start ", and " l_len
550fields of
551.IR lock .
552If a conflicting lock is held by another process,
553this call returns \-1 and sets
554.I errno
555to
2d3e4b83
JL
556.BR EAGAIN .
557.TP
558.BR F_OFD_SETLKW " (\fIstruct flock *\fP)"
559As for
560.BR F_OFD_SETLK ,
561but if a conflicting lock is held on the file, then wait for that lock to be
99b5ab79
MK
562released.
563If a signal is caught while waiting, then the call is interrupted
564and (after the signal handler has returned) returns immediately
565(with return value \-1 and
2d3e4b83
JL
566.I errno
567set to
568.BR EINTR ;
569see
570.BR signal (7)).
571.TP
572.BR F_OFD_GETLK " (\fIstruct flock *\fP)"
573On input to this call,
574.I lock
575describes an open file description lock we would like to place on the file.
576If the lock could be placed,
577.BR fcntl ()
578does not actually place it, but returns
579.B F_UNLCK
580in the
581.I l_type
582field of
583.I lock
584and leaves the other fields of the structure unchanged.
99b5ab79
MK
585If one or more incompatible locks would prevent this lock being placed,
586then details about one of these locks are returned via
587.IR lock ,
588as described above for
589.BR F_GETLK .
c6d039a3 590.P
d2e429c1
MK
591In the current implementation,
592.\" commit 57b65325fe34ec4c917bc4e555144b4a94d9e1f7
593no deadlock detection is performed for open file description locks.
594(This contrasts with process-associated record locks,
595for which the kernel does perform deadlock detection.)
596.\"
73d8cece 597.SS Mandatory locking
f5cdb4b0
MK
598.IR Warning :
599the Linux implementation of mandatory locking is unreliable.
600See BUGS below.
e1124af0
MK
601Because of these bugs,
602and the fact that the feature is believed to be little used,
603since Linux 4.5, mandatory locking has been made an optional feature,
604governed by a configuration option
605.RB ( CONFIG_MANDATORY_FILE_LOCKING ).
7e59106e 606This feature is no longer supported at all in Linux 5.15 and above.
c6d039a3 607.P
9acee578
MK
608By default, both traditional (process-associated) and open file description
609record locks are advisory.
fea681da 610Advisory locks are not enforced and are useful only between
c13182ef 611cooperating processes.
c6d039a3 612.P
9acee578 613Both lock types can also be mandatory.
c13182ef 614Mandatory locks are enforced for all processes.
00d7bbcf
MK
615If a process tries to perform an incompatible access (e.g.,
616.BR read (2)
617or
618.BR write (2))
619on a file region that has an incompatible mandatory lock,
620then the result depends upon whether the
621.B O_NONBLOCK
622flag is enabled for its open file description.
c13182ef 623If the
00d7bbcf
MK
624.B O_NONBLOCK
625flag is not enabled, then
6799ba26 626the system call is blocked until the lock is removed
00d7bbcf 627or converted to a mode that is compatible with the access.
c13182ef
MK
628If the
629.B O_NONBLOCK
00d7bbcf 630flag is enabled, then the system call fails with the error