Linux, inotify - how to subscribe?

Could you explain the inotify mechanism to me? I searched the Internet about this, but I realized that if I want to see the changes in the file, I have to do a survey using the "read" function. Is there a callback function that will notify me when a file has changes without polling?

Thank,

+5
source share
4 answers

I assume that you are using some kind of graphics library that handles events for you.

The best GUI libraries have the ability to look at file descriptors. In GTK it is ; in Qt, QSocketNotifier may work for you.

+2
source

inotify . FDs select() . , , .

+1

You can use the ev_io part of the libev library. This will allow you to set a callback when reading inotify fd is possible.

The libev documentation can be found here: http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod

+1
source

No, inotify requires a survey.

Registering a callback using a signal (as suggested), IMO is worse than regular polling.

0
source

All Articles