Skip to content

Commit

Permalink
Merge pull request #41 from shogo82148/port-475
Browse files Browse the repository at this point in the history
macos: retry if open() returns EINTR
  • Loading branch information
shogo82148 committed Mar 6, 2024
2 parents 999f629 + 57ba231 commit 3e50572
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions kqueue.go
Expand Up @@ -227,8 +227,17 @@ func (w *Watcher) addWatch(name string, flags uint32) (string, error) {
}
}

watchfd, err = unix.Open(name, openMode, 0700)
if watchfd == -1 {
// Retry on EINTR; open() can return EINTR in practice on macOS.
// See #354, and go issues 11180 and 39237.
for {
watchfd, err = unix.Open(name, openMode, 0)
if err == nil {
break
}
if errors.Is(err, unix.EINTR) {
continue
}

return "", err
}

Expand Down

0 comments on commit 3e50572

Please sign in to comment.