From 8e0bc2c3a858118fa9f4c2532d43b71b39b0adc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 21 Mar 2025 16:23:31 +0100 Subject: [PATCH] `MonitorFdHup`: raise explicit SysError rather unreachable Syscalls can fail for many reasons and we don't want to loose the errno and error context. --- src/libutil/unix/monitor-fd.hh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libutil/unix/monitor-fd.hh b/src/libutil/unix/monitor-fd.hh index cfbf10d5a..0829c1309 100644 --- a/src/libutil/unix/monitor-fd.hh +++ b/src/libutil/unix/monitor-fd.hh @@ -39,8 +39,11 @@ public: #endif ; auto count = poll(fds, 1, -1); - if (count == -1) - unreachable(); + if (count == -1) { + if (errno == EINTR || errno == EAGAIN) + continue; + throw SysError("failed to poll() in MonitorFdHup"); + } /* This shouldn't happen, but can on macOS due to a bug. See rdar://37550628.