You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multiple calls per watch event on linux with rb-inotify #98
Guard is watching for :close_write and :modify events. A modify event gets triggered for every 4k block written by the editor. If guard just listened for :close_write it would only trigger once when the editor has closed the file handle. I can't really think of any situation where :modify would be needed, but there may be some.
modify
A watched file or a file within a watched directory was written to.
close_write
A watched file or a file within a watched directory was closed, after being opened
in writeable mode. This does not necessarily imply the file was written to.
So when the editor writes a file in chunks, it fires several :modify and a single :close_write. So from my understanding, when removing :modify from the listener, we'll catch only the end of the write operation. However there may be other editors that keeps a file handle open and thus fires only :modify events.
I'm not sure how to approach this, since it may break another editor and I'm not using Linux on my development machine. I'd like to see more analysis of inotify events for other popular editors like vim, nano, joe, gedit, kate, SciTE, etc.
Here is the inotifywatch output from a few common editors. I opened the file, launched inotifywatch, changed it, saved it, killed inotify watch:
Sublime Text
total modify close_write open filename
5 3 1 1 coffee/script.coffee
Vim
total attrib move_self delete_self filename
4 1 1 1 coffee/script.coffee
Gedit
total access attrib close_write close_nowrite open delete_self filename
8 1 1 1 1 2 1 coffee/script.coffee
nano
total modify close_write open filename
5 3 1 1 coffee/script.coffee
joe
total access modify attrib close_write close_nowrite open filename
10 1 4 1 1 1 2 coffee/script.coffee
jedit
total move_self filename
1 1 coffee/script.coffee
scite
total modify close_write open filename
5 3 1 1 coffee/script.coffee
bluefish
total attrib close_write open filename
4 2 1 1 coffee/script.coffee
echo 'foo' > coffee/test.txt
total modify close_write open filename
4 2 1 1 coffee/test.txt
It looks to me like everything has a close_write except for a few that have neither close_write nor modify. I think these ones write to a tmp file and then move it into place over the existing file.
Seems like supporting only close_write & move_self (for vim & jedit) would cover 100% of editors listed above. Thanks these info, that's really helpful!
Activity
netzpirat commentedon Jun 29, 2011
From the inotifywatch man page:
So when the editor writes a file in chunks, it fires several
:modifyand a single:close_write. So from my understanding, when removing:modifyfrom the listener, we'll catch only the end of the write operation. However there may be other editors that keeps a file handle open and thus fires only:modifyevents.I'm not sure how to approach this, since it may break another editor and I'm not using Linux on my development machine. I'd like to see more analysis of inotify events for other popular editors like vim, nano, joe, gedit, kate, SciTE, etc.
jeffutter commentedon Jun 29, 2011
Here is the inotifywatch output from a few common editors. I opened the file, launched inotifywatch, changed it, saved it, killed inotify watch:
Sublime Text
Vim
Gedit
nano
joe
jedit
scite
bluefish
echo 'foo' > coffee/test.txt
It looks to me like everything has a close_write except for a few that have neither close_write nor modify. I think these ones write to a tmp file and then move it into place over the existing file.
netzpirat commentedon Jun 29, 2011
Awesome job! I will take care of it tomorrow. Thanks a lot.
thibaudgg commentedon Jun 29, 2011
Seems like supporting only
close_write&move_self(for vim & jedit) would cover 100% of editors listed above. Thanks these info, that's really helpful!schadenfred commentedon Jun 29, 2011
I'd like to add this issue, which is now closed, to this thread:
guard/guard-rspec#26 (comment)
thibaudgg commentedon Jul 2, 2011
Fixed in this commit
jonmast commentedon Jan 12, 2014
With Kate 3.12 run_on_modifications is no longer being fired. Output from inotifywatch is:
rymai commentedon Jan 14, 2014
@onlineamateur Please report any listener issue directly in the Listen issue tracker since it's handled there now. Thanks!