From 7ea9131e8ea2491e6132c7c28e89af844bfb9489 Mon Sep 17 00:00:00 2001 From: Pieter Droogendijk Date: Thu, 5 Feb 2015 22:19:17 +0100 Subject: [PATCH] inotify: Retry read on EINTR closes #62 --- CHANGELOG.md | 4 ++++ inotify.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55a4e7b..fe4c3ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.1.1 / 2015-02-05 + +* inotify: Retry read on EINTR [#61](https://github.com/go-fsnotify/fsnotify/issues/61) (thanks @PieterD) + ## v1.1.0 / 2014-12-12 * kqueue: rework internals [#43](https://github.com/go-fsnotify/fsnotify/pull/43) diff --git a/inotify.go b/inotify.go index f5c0aae..1a693f3 100644 --- a/inotify.go +++ b/inotify.go @@ -142,6 +142,12 @@ func (w *Watcher) readEvents() { } n, errno = syscall.Read(w.fd, buf[:]) + // If a signal interrupted execution, see if we've been asked to close, and try again. + // http://man7.org/linux/man-pages/man7/signal.7.html : + // "Before Linux 3.8, reads from an inotify(7) file descriptor were not restartable" + if errno == syscall.EINTR { + continue + } // If EOF is received if n == 0 {