bodokaiser
bodokaiser

Reputation: 15742

Difference between inotify and epoll

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

inotify

epoll

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?

Upvotes: 30

Views: 9617

Answers (1)

xaxxon
xaxxon

Reputation: 19751

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.

http://en.wikipedia.org/wiki/Inotify

Upvotes: 38

Related Questions