tail icon indicating copy to clipboard operation
tail copied to clipboard

StartTail followed by append to file is race-prone

Open ravenblackx opened this issue 3 years ago • 0 comments

If you StartTail(file_x) following from end, and then append "hello\n" to file_x, there's a race that makes it uncertain whether your appended line will come out of the tail operation or not; the StartTail operation seeks the end of the file in its own goroutine, and provides no signal that it has done so, so there's no way to reliably force the ordering of the operations.

https://github.com/nxadm/tail/pull/48 adds a config option "SyncOpen" that allows StartTail to perform any requested seek synchronously before it returns, thereby guaranteeing an order of operations.

ravenblackx avatar Jun 07 '22 21:06 ravenblackx