Skip to content

Commit

Permalink
Merge pull request #2 from windmilleng/jazzdan/fix_debug_macos
Browse files Browse the repository at this point in the history
Fix debugging on macos
  • Loading branch information
Dan Miller committed May 25, 2018
2 parents 28ae2b8 + b63213b commit 0b53a2c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,23 @@ func register(kq int, fds []int, flags int, fflags uint32) error {
return nil
}

func min(x int, y int) int {
if x < y {
return x
}

return y
}

// read retrieves pending events, or waits until an event occurs.
// A timeout of nil blocks indefinitely, while 0 polls the queue.
func read(kq int, events []unix.Kevent_t, timeout *unix.Timespec) ([]unix.Kevent_t, error) {
n, err := unix.Kevent(kq, nil, events, timeout)
if err != nil {
return nil, err
}
// https://github.com/fsnotify/fsnotify/issues/212#issuecomment-360862770
n = min(n, len(events)-1)
return events[0:n], nil
}

Expand Down

0 comments on commit 0b53a2c

Please sign in to comment.