tail icon indicating copy to clipboard operation
tail copied to clipboard

Concurrent usage of tail results in unexpected behavior

Open lovromazgon opened this issue 3 years ago • 1 comments

Describe the bug If two (or more) goroutines are tailing the same file and one of them stops it impacts the other goroutine(s).

Expected behaviour Other goroutines should keep on tailing the file.

To Reproduce See this test.

It runs three goroutines, one will continuously write to a file every 500 milliseconds, the other two will each tail the same file. The writing goroutine runs for 5 seconds, the first tailing goroutine runs for 2 seconds and the second tailing goroutine runs for 4 seconds.

The expectation is that the second goroutine would keep on tailing the file after the first one stops, but that is not the case.

System information

  • tail version 1.4.8
  • OS: macOS Monterey 12.3.1
  • Arch: amd64

Additional context The issue is (presumably) that both goroutines use the same underlying watcher and after one stops the watcher is removed.

lovromazgon avatar Apr 15 '22 11:04 lovromazgon

~I just realized there's a closed issue that points out this problem already https://github.com/nxadm/tail/issues/30.~

Scratch that, it's not the same.

lovromazgon avatar Apr 15 '22 11:04 lovromazgon