jordansissel/ruby-filewatch — pull request #16 by thesolution (2013-04-04 00:19:59+00:00)
Title: Add Env Var setting to close the file after reading. This will fix issues in Windows

This commit will fix two issues in Windows when using tail.
1. If the program writing logs does not set ShareMode flags, the open operation on the file fails and messages are not written.
2. Tail is locking the log file(s) so they cannot be deleted.

In Windows if the program writing logs opens the file with dwShareMode=0
the log writing operation fails. Closing the file after reading allows
the writing process to obtain the exclusive lock. This also allows for
rolling logs to work in windows since the file lock is released after
each read operation.
Usage:
Windows: set CloseAfterRead=true
Ruby: ENV["CloseAfterRead"] = "true"
Mac/Linux: Export CloseAfterRead=true