From 0400d2c630b27acf8dc821e7c87233ff3fc176d8 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Thu, 14 Dec 2017 14:05:57 +0100 Subject: [PATCH] Fix #100 allowing to tail named pipes `hpcloud/tail` supports tailing named pipe if we tell it to do so. This patch detects if the tailed file is a named pipe and configure `hpcloud/tail` accordingly. Note that it probably works only on Unix. Signed-off-by: Brice Figureau --- tail.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tail.go b/tail.go index c74a295..26baece 100644 --- a/tail.go +++ b/tail.go @@ -11,11 +11,18 @@ import ( func tailFile(ctx context.Context, file string, poll bool, dest *os.File) { defer wg.Done() + + s, err := os.Stat(file) + if err != nil { + log.Fatalf("unable to stat %s: %s", file, err) + } + t, err := tail.TailFile(file, tail.Config{ Follow: true, ReOpen: true, Poll: poll, Logger: tail.DiscardingLogger, + Pipe: s.Mode()&os.ModeNamedPipe != 0, }) if err != nil { log.Fatalf("unable to tail %s: %s", "foo", err)