Debian Codegraph @

upstream/debian-unstable/man2/F_GETFL.2const

raw
1 .\" Copyright, the authors of the Linux man-pages project
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .TH F_GETFL 2const 2026-01-05 "Linux man-pages 6.18"
6 .SH NAME
7 F_GETFL,
8 F_SETFL
9 \-
10 get/set file status flags
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ,\~ \-lc )
14 .SH SYNOPSIS
15 .nf
16 .B #include <fcntl.h>
17 .P
18 .BI "int fcntl(int " fd ", F_GETFL);"
19 .BI "int fcntl(int " fd ", F_SETFL, int " arg );
20 .fi
21 .SH DESCRIPTION
22 Each open file description has certain associated status flags,
23 initialized by
24 .BR open (2)
25 .\" or
26 .\" .BR creat (2),
27 and possibly modified by
28 .BR fcntl (2).
29 Duplicated file descriptors
30 (made with
31 .BR dup (2),
32 .BR F_DUPFD (2const),
33 .BR fork (2),
34 etc.) refer to the same open file description, and thus
35 share the same file status flags.
36 .P
37 The file status flags and their semantics are described in
38 .BR open (2).
39 .TP
40 .B F_GETFL
41 Return (as the function result)
42 the file access mode and the file status flags;
43 .I arg
44 is ignored.
45 .TP
46 .B F_SETFL
47 Set the file status flags to the value specified by
48 .IR arg .
49 File access mode
50 .RB ( O_RDONLY ", " O_WRONLY ", " O_RDWR )
51 and file creation flags
52 (i.e.,
53 .BR O_CREAT ", " O_EXCL ", " O_NOCTTY ", " O_TRUNC )
54 in
55 .I arg
56 are ignored.
57 On Linux, this operation can change only the
58 .BR O_APPEND ,
59 .BR O_ASYNC ,
60 .BR O_DIRECT ,
61 .BR O_NOATIME ,
62 and
63 .B O_NONBLOCK
64 flags.
65 It is not possible to change the
66 .B O_DSYNC
67 and
68 .B O_SYNC
69 flags;
70 see BUGS, below.
71 .SH RETURN VALUE
72 .TP
73 .B F_GETFL
74 Value of file status flags.
75 .TP
76 .B F_SETFL
77 Zero.
78 .P
79 On error, \-1 is returned, and
80 .I errno
81 is set to indicate the error.
82 .SH ERRORS
83 See
84 .BR fcntl (2).
85 .TP
86 .B EPERM
87 Attempted to clear the
88 .B O_APPEND
89 flag on a file that has the append-only attribute set.
90 .SH STANDARDS
91 POSIX.1-2024.
92 .SH HISTORY
93 SVr4,
94 4.3BSD,
95 POSIX.1-1988.
96 .SH BUGS
97 .SS F_SETFL
98 It is not possible to use
99 .B F_SETFL
100 to change the state of the
101 .B O_DSYNC
102 and
103 .B O_SYNC
104 flags.
105 .\" FIXME . According to POSIX.1-2001, O_SYNC should also be modifiable
106 .\" via fcntl(2), but currently Linux does not permit this
107 .\" See http://bugzilla.kernel.org/show_bug.cgi?id=5994
108 Attempts to change the state of these flags are silently ignored.
109 .SH SEE ALSO
110 .BR fcntl (2),
111 .BR open (2)