From 58af82c27b8b37f4c969c478a5de850666880777 Mon Sep 17 00:00:00 2001 From: Ian Gordon Date: Mon, 20 Jul 2026 22:13:22 -0400 Subject: [PATCH] Retry kevent on EINTR instead of failing kevent(2) can return -1/EINTR when a signal is delivered before any events arrive (e.g. debugger pause/resume). getNotifications treated this as fatal, unwinding SocketPool.run() and cancelling all waiters. Return no events instead so the caller polls again, matching the epoll_wait fix in a196c2e. Co-Authored-By: Claude Fable 5 --- FlyingSocks/Sources/SocketPool+kQueue.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/FlyingSocks/Sources/SocketPool+kQueue.swift b/FlyingSocks/Sources/SocketPool+kQueue.swift index d05dbe0b..fff33f54 100644 --- a/FlyingSocks/Sources/SocketPool+kQueue.swift +++ b/FlyingSocks/Sources/SocketPool+kQueue.swift @@ -133,6 +133,11 @@ public struct kQueue: EventQueue { var events = Array(repeating: kevent(), count: eventsLimit) let status = kevent(file.rawValue, nil, 0, &events, Int32(eventsLimit), nil) guard status > 0 else { + // EINTR (signal) is not a failure: report no events so the caller + // polls again rather than tearing down the server. See kevent(2). + if status == -1 && errno == EINTR { + return [] + } throw SocketError.makeFailed("kqueue kevent") }