I would like to know what the difference is between both i/o watchers inotify and epoll?
inotify
- 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
- 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?