hpcloud / tail

Go package for reading from continously updated files (tail -f)
MIT License
2.71k stars 503 forks source link

inotify.go: Fix bug where inotify returns IN_ATTRIB against an open fd when deleted #101

Closed TerraTech closed 7 years ago

TerraTech commented 8 years ago

While investigating why deleting a log file, then recreating and writing to it, tail would not ReOpen the log file.

As a test:

echo foo > test.log
tail -f test.log &
inotifywait -m test.log &
rm test.log (at this point, inotify issues an IN_ATTRIB on an open fd)
echo bar > test.log  (tail does not reopen)
kill $(pidof tail)  (now inotify will issue an IN_DELETE_SELF as the fd is closed and the inode is able to be purged from the filesystem)

The patch I'm submitting tests for this case and fallsthrough into the fsnotify.Remove code, which appears to handle it correctly.

Please look it over and let me know if this was the correct way to fix the problem.

As an aside, I'm also using this patch: https://github.com/hpcloud/tail/pull/99 (Tailing stop bug fix)

alertedsnake commented 7 years ago

Any update on when this can be merged? Seems like this project has become abandonware...

TerraTech commented 7 years ago

@Mook-as is this project still active?

Nino-K commented 7 years ago

@TerraTech Thanks for your contribution.