File: fcntl.2

package info (click to toggle)
manpages 6.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,184 kB
  • sloc: sh: 575; python: 222; perl: 190; makefile: 29; lisp: 22
file content (146 lines) | stat: -rw-r--r-- 2,901 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH fcntl 2 2025-07-20 "Linux man-pages (unreleased)"
.SH NAME
fcntl \- manipulate file descriptor
.SH LIBRARY
Standard C library
.RI ( libc ,\~ \-lc )
.SH SYNOPSIS
.nf
.B #include <fcntl.h>
.P
.BI "int fcntl(int " fd ", int " op ", ...);"
.fi
.SH DESCRIPTION
.BR fcntl ()
performs one of the operations described below on the open file descriptor
.IR fd .
The operation is determined by
.IR op .
.P
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
.BR fcntl ()
with the desired
.I op
value and then test whether the call failed with
.BR EINVAL ,
indicating that the kernel does not recognize this value.
.SS Duplicating a file descriptor
.TP
.BR F_DUPFD (2const)
.TQ
.BR F_DUPFD_CLOEXEC (2const)
.SS File descriptor flags
.TP
.BR F_GETFD (2const)
.TQ
.BR F_SETFD (2const)
.SS File status flags
.TP
.BR F_GETFL (2const)
.TQ
.BR F_SETFL (2const)
.SS Advisory record locking
.TP
.BR F_SETLK (2const)
.TQ
.BR F_SETLKW (2const)
.TQ
.BR F_GETLK (2const)
.SS Open file description locks (non-POSIX)
.TP
.BR F_OFD_SETLK (2const)
.TQ
.BR F_OFD_SETLKW (2const)
.TQ
.BR F_OFD_GETLK (2const)
.SS Managing signals
.TP
.BR F_GETOWN (2const)
.TQ
.BR F_SETOWN (2const)
.TQ
.BR F_GETOWN_EX (2const)
.TQ
.BR F_SETOWN_EX (2const)
.TQ
.BR F_GETSIG (2const)
.TQ
.BR F_SETSIG (2const)
.SS Leases
.TP
.BR F_SETLEASE (2const)
.TQ
.BR F_GETLEASE (2const)
.SS File and directory change notification (dnotify)
.TP
.BR F_NOTIFY (2const)
.SS Changing the capacity of a pipe
.TP
.BR F_SETPIPE_SZ (2const)
.TQ
.BR F_GETPIPE_SZ (2const)
.SS File Sealing
.TP
.BR F_ADD_SEALS (2const)
.TQ
.BR F_GET_SEALS (2const)
.SS File read/write hints
.TP
.BR F_GET_RW_HINT (2const)
.TQ
.BR F_SET_RW_HINT (2const)
.TQ
.BR F_GET_FILE_RW_HINT (2const)
.TQ
.BR F_SET_FILE_RW_HINT (2const)
.SH RETURN VALUE
For a successful call, the return value depends on the operation.
.P
On error, \-1 is returned, and
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.BR EACCES " or " EAGAIN
Operation is prohibited by locks held by other processes.
.TP
.B EAGAIN
The operation is prohibited because the file has been memory-mapped by
another process.
.TP
.B EBADF
.I fd
is not an open file descriptor
.TP
.B EINVAL
The value specified in
.I op
is not recognized by this kernel.
.SH VERSIONS
POSIX.1-2024 specifies
.B FD_CLOFORK
and
.BR F_DUPFD_CLOFORK ,
but Linux doesn't support them.
.SH STANDARDS
POSIX.1-2008.
.\" .P
.\" SVr4 documents additional EIO, ENOLINK and EOVERFLOW error conditions.
.SH HISTORY
SVr4, 4.3BSD, POSIX.1-2001.
.SH SEE ALSO
.BR dup2 (2),
.BR flock (2),
.BR open (2),
.BR socket (2),
.BR lockf (3),
.BR capabilities (7),
.BR feature_test_macros (7),
.BR lslocks (8)