From 0b9f044bb364bc4932c81f3d54800872fbabd0b8 Mon Sep 17 00:00:00 2001 From: Andy Ouyang Date: Mon, 3 Aug 2015 14:38:42 -0700 Subject: [PATCH] Ignoring EINTR (ctrl+Z) signal --- watch/inotify_tracker.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/watch/inotify_tracker.go b/watch/inotify_tracker.go index b00b4fc..b937621 100644 --- a/watch/inotify_tracker.go +++ b/watch/inotify_tracker.go @@ -6,6 +6,7 @@ import ( "log" "os" "sync" + "syscall" "github.com/hpcloud/tail/util" @@ -113,8 +114,12 @@ func (shared *InotifyTracker) run() { case err, open := <-shared.watcher.Error: if !open { return + } else if err != nil { + sysErr, ok := err.(*os.SyscallError) + if !ok || sysErr.Err != syscall.EINTR { + logger.Printf("Error in Watcher Error channel: %s", err) + } } - logger.Printf("Error in Watcher Errors channel: %s", err) case <-shared.done: return