Inotify not activate file change notifications

I have now set up an example so that it constantly looks at the file for "modifications." My code is here . In my tests, the inotify notification is only triggered when the file is first changed (i.e. touch'ed). Any subsequent changes to the file do not result in any notifications. statindicates that the "Change" time has changed. In addition, changing the code to delete the clock and re-add each time a notification is triggered (i.e., Moving inotify_add_watchand inotify_rm_watchin cycle while(1)c) did not help to solve this problem.

I was wondering if anyone could help me on what I might be doing wrong. Also, although I added a watch for IN_ALL_EVENTS, I really only care about events IN_MODIFY. Not sure if that matters.

Also, does this use case not work? Should I change my approach for browsing the catalog? Please advice.

TIA.

Edit 1: as noted by itel , processing irequires some fixing. However, even the fixed version does not trigger notifications for subsequent "file system" events. In addition, adding a clock to a directory, unlike a file, exhibits similar non-deterministic behavior.

Edit 2: I would like to get this asio + inotify example based on this answer to work. Unfortunately, this example did not work for me at all. Any help is appreciated. TIA.

+5
source share
3 answers

After fixing with itel, your code works fine when browsing the directory in my tests. When viewing a file, it event->lenis zero, and your code ignores notifications.

With the test for event->lendeleted and all event->namereplaced with file_pathin printf statements, it works fine when viewing a file.

PS: Just noticed what you mentioned touch.

touch dispatches the following events:

IN_OPEN
IN_ATTRIB
IN_CLOSE_WRITE

no IN_MODIFY

, , vim, - , , . pico .

+2

i , reset 0 . , inotify , , , .

.

+2

when monitoring a single event-> len file, it will be 0 because the file name is not returned. I noticed that many sample programs have this problem.

0
source

All Articles