From 3c6882b4b35d4dcf756a540d350410cd4309d14e Mon Sep 17 00:00:00 2001 From: ddirect <62487612+ddirect@users.noreply.github.com> Date: Sun, 18 Jan 2026 19:05:43 +0200 Subject: [PATCH] Repeating select call on Bridge when interrupted (#20) * Repeating select if it is interrupted * Restrict retries for syscall.EINTR to 10 Limit the number of retries on syscall.EINTR to 10. --------- Co-authored-by: Pat Whittingslow --- internal/tap.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/tap.go b/internal/tap.go index 784a6b0..6923f9b 100644 --- a/internal/tap.go +++ b/internal/tap.go @@ -284,8 +284,15 @@ func (br *Bridge) Poll(timeout time.Duration) (bool, error) { Sec: int64(timeout / time.Second), Usec: int64((timeout % time.Second) / time.Microsecond), } + retry := 0 +again: n, err := syscall.Select(br.fd+1, &readfds, nil, nil, &tv) + retry++ if err != nil { + if err == syscall.EINTR && retry <= 10 { + // under linux, select updates tv with the remaining time + goto again + } return false, err } return n > 0, nil