Skip to content

Commit 846b32d

Browse files
Dan Millernicks
authored andcommitted
Fix debugging on macos
1 parent 8a5d4ab commit 846b32d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

kqueue.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,23 @@ func register(kq int, fds []int, flags int, fflags uint32) error {
517517
return nil
518518
}
519519

520+
func min(x int, y int) int {
521+
if x < y {
522+
return x
523+
}
524+
525+
return y
526+
}
527+
520528
// read retrieves pending events, or waits until an event occurs.
521529
// A timeout of nil blocks indefinitely, while 0 polls the queue.
522530
func read(kq int, events []unix.Kevent_t, timeout *unix.Timespec) ([]unix.Kevent_t, error) {
523531
n, err := unix.Kevent(kq, nil, events, timeout)
524532
if err != nil {
525533
return nil, err
526534
}
535+
// https://github.com/fsnotify/fsnotify/issues/212#issuecomment-360862770
536+
n = min(n, len(events)-1)
527537
return events[0:n], nil
528538
}
529539

0 commit comments

Comments
 (0)