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
Calling Cleanup() on a Tail can decrement the watch counter below zero, which can prevent future attempts to tail the file.
Here is some code that can be used to show the issue:
funcmain() {
// Setup and tail, being careful to avoid issue #93t, err:=tail.TailFile(os.Args[1], tail.Config{Follow: true})
iferr!=nil {
fmt.Println(err)
}
gofunc() {
forline:=ranget.Lines {
}
}()
t.Stop()
t.Cleanup()
// At this point, the watch count for this is negative, the next time we// try to tail a watch will not be set.t, err=tail.TailFile(os.Args[1], tail.Config{Follow: true})
iferr!=nil {
fmt.Println(err)
}
gofunc() {
forline:=ranget.Lines {
fmt.Printf("%q\n", line.Text)
}
}()
t.Wait()
}
To duplicate:
go run ./main.go test.log
# from another shell
echo 1 >> test.log
echo 2 >> test.log
Expected: the lines appended to test.log should be printed to screen.
Actual: no output
Looking into the history of this function, it appears it was originally added to close all inotify watches before the program exists and it did not originally require access to the Tail objects.
Since now you need the Tail to call, it seems preferrable to call Stop() instead. The Cleanup function also does not ensure that the watch count goes to zero, it just does a single decrement, which won't be enough if there are multiple tails on a file.
The text was updated successfully, but these errors were encountered:
Calling Cleanup() on a Tail can decrement the watch counter below zero, which can prevent future attempts to tail the file.
Here is some code that can be used to show the issue:
To duplicate:
Expected: the lines appended to test.log should be printed to screen.
Actual: no output
Looking into the history of this function, it appears it was originally added to close all inotify watches before the program exists and it did not originally require access to the Tail objects.
Since now you need the Tail to call, it seems preferrable to call Stop() instead. The Cleanup function also does not ensure that the watch count goes to zero, it just does a single decrement, which won't be enough if there are multiple tails on a file.
The text was updated successfully, but these errors were encountered: