---
name: "F_NOTIFY"
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_NOTIFY"
---

# F\_NOTIFY(2const)

file and directory change notification

## NAME

F\_NOTIFY - file and directory change notification

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#define _GNU_SOURCE
#include <fcntl.h>
```

**int fcntl(int** *fd***, F\_NOTIFY, int** *arg***);**

## DESCRIPTION

Provide notification when the directory referred to by *fd* or any of the files that it contains is changed. The events to be notified are specified in *arg*, which is a bit mask specified by ORing together zero or more of the following bits:

- **DN\_ACCESS**

  A file was accessed ([**read**(2)](/read/2.md), [**pread**(2)](/pread/2.md), [**readv**(2)](/readv/2.md), and similar)

- **DN\_MODIFY**

  A file was modified ([**write**(2)](/write/2.md), [**pwrite**(2)](/pwrite/2.md), [**writev**(2)](/writev/2.md), [**truncate**(2)](/truncate/2.md), [**ftruncate**(2)](/ftruncate/2.md), and similar).

- **DN\_CREATE**

  A file was created ([**open**(2)](/open/2.md), [**creat**(2)](/creat/2.md), [**mknod**(2)](/mknod/2.md), [**mkdir**(2)](/mkdir/2.md), [**link**(2)](/link/2.md), [**symlink**(2)](/symlink/2.md), [**rename**(2)](/rename/2.md) into this directory).

- **DN\_DELETE**

  A file was unlinked ([**unlink**(2)](/unlink/2.md), [**rename**(2)](/rename/2.md) to another directory, [**rmdir**(2)](/rmdir/2.md)).

- **DN\_RENAME**

  A file was renamed within this directory ([**rename**(2)](/rename/2.md)).

- **DN\_ATTRIB**

  The attributes of a file were changed ([**chown**(2)](/chown/2.md), [**chmod**(2)](/chmod/2.md), [**utime**(2)](/utime/2.md), [**utimensat**(2)](/utimensat/2.md), and similar).

(In order to obtain these definitions, the **\_GNU\_SOURCE** feature test macro must be defined before including *any* header files.)

Directory notifications are normally "one-shot", and the application must reregister to receive further notifications. Alternatively, if **DN\_MULTISHOT** is included in *arg*, then notification will remain in effect until explicitly removed.

A series of **F\_NOTIFY** requests is cumulative, with the events in *arg* being added to the set already monitored. To disable notification of all events, make an **F\_NOTIFY** call specifying *arg* as 0.

Notification occurs via delivery of a signal. The default signal is **SIGIO**, but this can be changed using the **F\_SETSIG** operation to **fcntl**(). (Note that **SIGIO** is one of the nonqueuing standard signals; switching to the use of a real-time signal means that multiple notifications can be queued to the process.) In the latter case, the signal handler receives a *siginfo\_t* structure as its second argument (if the handler was established using **SA\_SIGINFO**) and the *si\_fd* field of this structure contains the file descriptor which generated the notification (useful when establishing notification on multiple directories).

Especially when using **DN\_MULTISHOT**, a real time signal should be used for notification, so that multiple notifications can be queued.

**NOTE:** New applications should use the *inotify* interface (available since Linux 2.6.13), which provides a much superior interface for obtaining notifications of filesystem events. See [**inotify**(7)](/inotify/7.md).

## RETURN VALUE

Zero.

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

## ERRORS

See [**fcntl**(2)](/fcntl/2.md).

- **ENOTDIR**

  *fd* does not refer to a directory.

## STANDARDS

Linux.

## HISTORY

Linux 2.4.

## SEE ALSO

[**fcntl**(2)](/fcntl/2.md)
