Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux, inotify - how to subscribe?

Tags:

c++

linux

inotify

Can you please explain me the inotify mechanism? I’ve searched in the web about it, but what I understood is that if I want to see the changes in a file I have to do polling with the “read” function. Is there any callback function which will notify me when the file has a change without polling?

Thanks,

like image 433
devdev Avatar asked Oct 13 '22 21:10

devdev


1 Answers

I'm speculating that you are using some GUI library that handle events for you.

The better GUI libraries have a way to watch file descriptors. In GTK, it is gtk_input_add_full; in Qt, QSocketNotifier might work for you.

like image 57
bew Avatar answered Oct 25 '22 04:10

bew