48
48
#include <error.h> /* error() */
49
49
#include <sysexits.h> /* EX_USAGE, EX_OSERR, EX_OSFILE */
50
50
#include <errno.h> /* errno, error_t, EACCES,
51
ENAMETOOLONG, ENOENT, EEXIST,
52
ECHILD, EPERM, ENOMEM, EAGAIN,
53
EINTR, ENOBUFS, EADDRINUSE,
51
ENAMETOOLONG, ENOENT, ENOTDIR,
52
EEXIST, ECHILD, EPERM, ENOMEM,
53
EAGAIN, EINTR, ENOBUFS, EADDRINUSE,
54
54
ECONNREFUSED, ECONNRESET,
55
55
ETOOMANYREFS, EMSGSIZE, EBADF,
84
84
#include <fcntl.h> /* O_CLOEXEC, O_NONBLOCK, fcntl(),
85
85
F_GETFD, F_GETFL, FD_CLOEXEC,
86
86
open(), O_WRONLY, O_NOCTTY,
87
O_RDONLY, O_NOFOLLOW */
88
88
#include <sys/wait.h> /* waitpid(), WNOHANG, WIFEXITED(),
90
90
#include <limits.h> /* PIPE_BUF, NAME_MAX, INT_MAX */
91
91
#include <sys/inotify.h> /* inotify_init1(), IN_NONBLOCK,
92
92
IN_CLOEXEC, inotify_add_watch(),
93
93
IN_CLOSE_WRITE, IN_MOVED_TO,
94
IN_DELETE, struct inotify_event */
94
IN_MOVED_FROM, IN_DELETE,
95
IN_EXCL_UNLINK, IN_ONLYDIR,
96
struct inotify_event */
95
97
#include <fnmatch.h> /* fnmatch(), FNM_FILE_NAME */
96
98
#include <stdio.h> /* asprintf(), FILE, fopen(),
97
99
getline(), sscanf(), feof(),