Debian Codegraph @

upstream/debian-unstable/man2/fcntl.2

raw
1 .\" Copyright 1992, Drew Eckhardt <[email protected]>
2 .\" Copyright 1992, Ian Jackson <[email protected]>
3 .\" Copyright 1998, Jamie Lokier <[email protected]>
4 .\" Copyright 2002-2012, Michael Kerrisk <[email protected]>
5 .\" Copyright 2014, Jeff Layton <[email protected]>
6 .\" Copyright 2014, David Herrmann <[email protected]>
7 .\" Copyright 2017, Jens Axboe <[email protected]>
8 .\" Copyright, the authors of the Linux man-pages project
9 .\"
10 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
11 .\"
12 .TH fcntl 2 2026-02-08 "Linux man-pages 6.18"
13 .SH NAME
14 fcntl \- manipulate file descriptor
15 .SH LIBRARY
16 Standard C library
17 .RI ( libc ,\~ \-lc )
18 .SH SYNOPSIS
19 .nf
20 .B #include <fcntl.h>
21 .P
22 .BI "int fcntl(int " fd ", int " op ", ...);"
23 .fi
24 .SH DESCRIPTION
25 .BR fcntl ()
26 performs one of the operations described below on the open file descriptor
27 .IR fd .
28 The operation is determined by
29 .IR op .
30 .P
31 Certain of the operations below are supported only since a particular
32 Linux kernel version.
33 The preferred method of checking whether the host kernel supports
34 a particular operation is to invoke
35 .BR fcntl ()
36 with the desired
37 .I op
38 value and then test whether the call failed with
39 .BR EINVAL ,
40 indicating that the kernel does not recognize this value.
41 .SS Duplicating a file descriptor
42 .TP
43 .BR F_DUPFD (2const)
44 .TQ
45 .BR F_DUPFD_CLOEXEC (2const)
46 .SS File descriptor flags
47 .TP
48 .BR F_GETFD (2const)
49 .TQ
50 .BR F_SETFD (2const)
51 .SS File status flags
52 .TP
53 .BR F_GETFL (2const)
54 .TQ
55 .BR F_SETFL (2const)
56 .SS Advisory record locking
57 .TP
58 .BR F_SETLK (2const)
59 .TQ
60 .BR F_SETLKW (2const)
61 .TQ
62 .BR F_GETLK (2const)
63 .SS Open file description locks (non-POSIX)
64 .TP
65 .BR F_OFD_SETLK (2const)
66 .TQ
67 .BR F_OFD_SETLKW (2const)
68 .TQ
69 .BR F_OFD_GETLK (2const)
70 .SS Managing signals
71 .TP
72 .BR F_GETOWN (2const)
73 .TQ
74 .BR F_SETOWN (2const)
75 .TQ
76 .BR F_GETOWN_EX (2const)
77 .TQ
78 .BR F_SETOWN_EX (2const)
79 .TQ
80 .BR F_GETSIG (2const)
81 .TQ
82 .BR F_SETSIG (2const)
83 .SS Leases
84 .TP
85 .BR F_SETLEASE (2const)
86 .TQ
87 .BR F_GETLEASE (2const)
88 .SS Delegations
89 .TP
90 .BR F_SETDELEG (2const)
91 .TQ
92 .BR F_GETDELEG (2const)
93 .SS File and directory change notification (dnotify)
94 .TP
95 .BR F_NOTIFY (2const)
96 .SS Changing the capacity of a pipe
97 .TP
98 .BR F_SETPIPE_SZ (2const)
99 .TQ
100 .BR F_GETPIPE_SZ (2const)
101 .SS File Sealing
102 .TP
103 .BR F_ADD_SEALS (2const)
104 .TQ
105 .BR F_GET_SEALS (2const)
106 .SS File read/write hints
107 .TP
108 .BR F_GET_RW_HINT (2const)
109 .TQ
110 .BR F_SET_RW_HINT (2const)
111 .TQ
112 .BR F_GET_FILE_RW_HINT (2const)
113 .TQ
114 .BR F_SET_FILE_RW_HINT (2const)
115 .SH RETURN VALUE
116 For a successful call, the return value depends on the operation.
117 .P
118 On error, \-1 is returned, and
119 .I errno
120 is set to indicate the error.
121 .SH ERRORS
122 .TP
123 .BR EACCES " or " EAGAIN
124 Operation is prohibited by locks held by other processes.
125 .TP
126 .B EAGAIN
127 The operation is prohibited because the file has been memory-mapped by
128 another process.
129 .TP
130 .B EBADF
131 .I fd
132 is not an open file descriptor
133 .TP
134 .B EINVAL
135 The value specified in
136 .I op
137 is not recognized by this kernel.
138 .SH VERSIONS
139 POSIX.1-2024 specifies
140 .B FD_CLOFORK
141 and
142 .BR F_DUPFD_CLOFORK ,
143 but Linux doesn't support them.
144 .SH STANDARDS
145 POSIX.1-2024.
146 .\" .P
147 .\" SVr4 documents additional EIO, ENOLINK and EOVERFLOW error conditions.
148 .SH HISTORY
149 4.3BSD,
150 SVr4,
151 POSIX.1-1988.
152 .SH SEE ALSO
153 .BR dup2 (2),
154 .BR flock (2),
155 .BR open (2),
156 .BR socket (2),
157 .BR lockf (3),
158 .BR capabilities (7),
159 .BR feature_test_macros (7),
160 .BR lslocks (8)