joyent / libuv

Go to
https://github.com/libuv/libuv
3.27k stars 653 forks source link

File system events stop working after file editing with vim #1585

Closed doppioandante closed 10 years ago

doppioandante commented 10 years ago
$ uname -a
Linux arch 3.17.3-1-ARCH #1 SMP PREEMPT Fri Nov 14 23:13:48 CET 2014 x86_64 GNU/Linux

The system is a guest inside virtualbox, but this should not be a problem in this case, as the file is not located in a shared folder. Steps to reproduce:

Program output:

➜  codes  ./test file.js
Adding watch on file.js
Change detected(1) in file.js: renamed file.js
Change detected(2) in file.js: changed file.js
Change detected(1) in file.js: renamed file.js
Change detected(1) in file.js: renamed file.js

Commands run:

 codes  ls
file.js  test  test.c
➜  codes  vim file.js
➜  codes  echo a > file.js
➜  codes  touch file.js
➜  codes  mv file.js file2.js
➜  codes  mv file2.js file.js

None of the above commands after vim editing is detected.

strace output: https://gist.github.com/doppioandante/67da576ec82c06b6ffd2

Using a different editor(I've tried nano) doesn't cause this bug. This led me to think that maybe the fd passed to inotify gets invalid after vim has done something strange while saving the file. I'm unable to test this on windows ATM.

indutny commented 10 years ago

Ok, as figured it out in IRC - the cause is VIM, who creates the tmp file, and removes original file, and moves the tmp file to original file's location. Not an issue.