bird1500
March 14th, 2013, 06:02 PM
Hi,
while tracking all (IN_ALL_EVENTS) file events with sys/inotify.h I got odd results when Geany modifies and saves a (text) file, for example:
a text file is open in Geany, I add a letter to the file (to change its contents) and click save (Ctrl+S), the Geany "save" action triggers the following odd inotify events (event->mask printed bitwise) in the following order:
events triggered when listening for IN_ALL_EVENTS
00000000 00000000 00000000 00100000 //IN_OPEN
00000000 00000000 00000000 00001000 //IN_CLOSE_WRITE
00000000 00000000 00000000 10000000 //IN_MOVED_TO
00000000 00000000 00000000 00001000 //IN_CLOSE_WRITE
00000000 00000000 00000000 00100000 //IN_OPEN
00000000 00000000 00000000 00000001 //IN_ACCESS
00000000 00000000 00000000 00010000 //IN_CLOSE_NOWRITE
Notice the event chain starts with "IN_OPEN" (but the file was already open in Geany), also, IN_MOVED_TO is typically used for renaming files.
So what is Geany doing?
I thought it should be as simple as: (1) IN_MODIFY and (2) IN_CLOSE_WRITE, end of story, no?
while tracking all (IN_ALL_EVENTS) file events with sys/inotify.h I got odd results when Geany modifies and saves a (text) file, for example:
a text file is open in Geany, I add a letter to the file (to change its contents) and click save (Ctrl+S), the Geany "save" action triggers the following odd inotify events (event->mask printed bitwise) in the following order:
events triggered when listening for IN_ALL_EVENTS
00000000 00000000 00000000 00100000 //IN_OPEN
00000000 00000000 00000000 00001000 //IN_CLOSE_WRITE
00000000 00000000 00000000 10000000 //IN_MOVED_TO
00000000 00000000 00000000 00001000 //IN_CLOSE_WRITE
00000000 00000000 00000000 00100000 //IN_OPEN
00000000 00000000 00000000 00000001 //IN_ACCESS
00000000 00000000 00000000 00010000 //IN_CLOSE_NOWRITE
Notice the event chain starts with "IN_OPEN" (but the file was already open in Geany), also, IN_MOVED_TO is typically used for renaming files.
So what is Geany doing?
I thought it should be as simple as: (1) IN_MODIFY and (2) IN_CLOSE_WRITE, end of story, no?