tail icon indicating copy to clipboard operation
tail copied to clipboard

Add SyncOpen config option

Open ravenblackx opened this issue 3 years ago • 0 comments

This new option allows the client to avoid the following race condition:

  1. open file "example.txt"
  2. StartTail("example.txt", Location: &SeekInfo(0, io.SeekEnd))
  3. append "hello\n" to example.txt

Without SyncOpen, this sequence may or may not see the line "hello" depending on a race between the goroutine that writes it and the goroutine that Tail runs.

With SyncOpen, the StartTail function doesn't return until the requested seek operation has been performed (unless the file doesn't exist, in which case no seek operation is performed, ensuring position 0 will be used when the file is created), so any writes performed after StartTail are guaranteed to be seen by the tail operation.

Addresses issue https://github.com/nxadm/tail/issues/49

ravenblackx avatar Jun 02 '22 16:06 ravenblackx