Provided by: manpages-dev_6.16-1_all bug

NAME

       F_GETFL, F_SETFL - get/set file status flags

LIBRARY

       Standard C library (libc, -lc)

SYNOPSIS

       #include <fcntl.h>

       int fcntl(int fd, F_GETFL);
       int fcntl(int fd, F_SETFL, int arg);

DESCRIPTION

       Each  open  file  description  has  certain  associated status flags, initialized by open(2) and possibly
       modified by fcntl(2).  Duplicated file descriptors (made with  dup(2),  F_DUPFD(2const),  fork(2),  etc.)
       refer to the same open file description, and thus share the same file status flags.

       The file status flags and their semantics are described in open(2).

       F_GETFL
              Return (as the function result) the file access mode and the file status flags; arg is ignored.

       F_SETFL
              Set  the  file  status flags to the value specified by arg.  File access mode (O_RDONLY, O_WRONLY,
              O_RDWR) and file creation flags (i.e., O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC) in arg are ignored.  On
              Linux, this operation can change only the O_APPEND, O_ASYNC, O_DIRECT, O_NOATIME,  and  O_NONBLOCK
              flags.  It is not possible to change the O_DSYNC and O_SYNC flags; see BUGS, below.

RETURN VALUE

       F_GETFL
              Value of file status flags.

       F_SETFL
              Zero.

       On error, -1 is returned, and errno is set to indicate the error.

ERRORS

       See fcntl(2).

       EPERM  Attempted to clear the O_APPEND flag on a file that has the append-only attribute set.

STANDARDS

       POSIX.1-2024.

HISTORY

       SVr4, 4.3BSD, POSIX.1-2001.

BUGS

   F_SETFL
       It  is  not  possible  to  use  F_SETFL to change the state of the O_DSYNC and O_SYNC flags.  Attempts to
       change the state of these flags are silently ignored.

SEE ALSO

       fcntl(2), open(2)

Linux man-pages 6.16                               2025-10-29                                    F_GETFL(2const)