1 #define DN_ACCESS 0x00000001 /* File accessed in directory */
2 #define DN_MODIFY 0x00000002 /* File modified in directory */
3 #define DN_CREATE 0x00000004 /* File created in directory */
4 #define DN_DELETE 0x00000008 /* File removed from directory */
5 #define DN_RENAME 0x00000010 /* File renamed in directory */
6 #define DN_ATTRIB 0x00000020 /* File changed attribute */
7 #define DN_MULTISHOT 0x80000000 /* Don't remove notifier */
10 #define _GNU_SOURCE /* needed to get the defines */
11 #include <fcntl.h> /* in glibc 2.2 this has the needed
19 static void handler(int sig, siginfo_t *si, void *data)
29 act.sa_sigaction = handler;
30 sigemptyset(&act.sa_mask);
31 act.sa_flags = SA_SIGINFO;
32 sigaction(SIGRTMIN, &act, NULL);
34 fd = open(".", O_RDONLY);
35 fcntl(fd, F_SETSIG, SIGRTMIN);
36 fcntl(fd, F_NOTIFY, DN_MODIFY|DN_CREATE|DN_MULTISHOT);
37 /* we will now be notified if any of the files
38 in "dir" is modified or new files are
42 printf("Got event on fd=%d\n", event_fd);