Difference between inotify and epoll

I would like to know what the difference is between both i/o watchers inotify and epoll?


  • inotify_init(void) creates inotify instance to read events from
  • inotify_add_watch(int fd, const char * path, int mask) returns a watch fd around the file node behind the path
  • inotify_rm_watch(int fd, int wd) stops watching for events on fd


  • epoll_create(void) creates epoll object
  • epoll_ctl(int epfd, int op, int fd, struct epoll_event * event) sets up events to watch
  • epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); blocks until event happens

So there seems to be a different approach on file watching. Inotify tries to let the user decide when to collect events while epoll blocks until something happens.

Is this correct? What are other differences?


The biggest difference is that epoll can be used for ANY fd. This means it’s good for watching all types of ways to communicate data. Sockets, IPC, files, printers.. anything. inotify is for filesystems only.

However, because inotify is specific to filesystems, you can receive notifications on a wide array of filesystem-specific attributes, such as file attributes and the file being read. These things are not possible via epoll.

In fact, inotify returns a file descriptor – which means you can use epoll to determine which inotify FD’s you should call read on. So the two go hand in hand to some extent.