Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,17 @@ func (tail *Tail) tailFileSync() {
// moved or truncated. When moved or deleted - the file will be
// reopened if ReOpen is true. Truncated files are always reopened.
func (tail *Tail) waitForChanges() error {
if tail.Pipe {
// If input is a fifo, we can reopen immediately
tail.Logger.Printf("Re-opening named pipe %s ...", tail.Filename)
if err := tail.reopen(); err != nil {
return err
}
tail.Logger.Printf("Successfully reopened pipe %s", tail.Filename)
tail.openReader()
return nil
}

if tail.changes == nil {
pos, err := tail.file.Seek(0, io.SeekCurrent)
if err != nil {
Expand Down Expand Up @@ -426,7 +437,11 @@ func (tail *Tail) openReader() {
}

func (tail *Tail) seekEnd() error {
return tail.seekTo(SeekInfo{Offset: 0, Whence: io.SeekEnd})
if !tail.Pipe {
return tail.seekTo(SeekInfo{Offset: 0, Whence: io.SeekEnd})
} else {
return nil
}
}

func (tail *Tail) seekTo(pos SeekInfo) error {
Expand Down