---
name: "F_SETFL"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/F_GETFL"
---

# F\_SETFL(2const)

get/set file status flags

Part of [F\_GETFL(2const)](/F_GETFL/2const.md).

## 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)](/open/2.md) and possibly modified by [**fcntl**(2)](/fcntl/2.md). Duplicated file descriptors (made with [**dup**(2)](/dup/2.md), [**F\_DUPFD**(2const)](/F_DUPFD/2const.md), [**fork**(2)](/fork/2.md), 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)](/open/2.md).

- **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)](/fcntl/2.md).

- **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-1988.

## 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)](/fcntl/2.md), [**open**(2)](/open/2.md)
