From 1a461baee1b1a568aeac081e64a435e37878025f Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 23 Mar 2025 17:58:50 -0400 Subject: [PATCH] `MonitorFdHup`: Cleanup a bit with designated initializers (cherry picked from commit d028bb4c4af2b502af21768eeae41e851dde74be) --- src/libutil/unix/monitor-fd.hh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/libutil/unix/monitor-fd.hh b/src/libutil/unix/monitor-fd.hh index 0829c1309..235a7db3c 100644 --- a/src/libutil/unix/monitor-fd.hh +++ b/src/libutil/unix/monitor-fd.hh @@ -25,19 +25,22 @@ public: thread = std::thread([fd]() { while (true) { /* Wait indefinitely until a POLLHUP occurs. */ - struct pollfd fds[1]; - fds[0].fd = fd; + struct pollfd fds[1] = { + { + .fd = fd, + .events = /* Polling for no specific events (i.e. just waiting for an error/hangup) doesn't work on macOS anymore. So wait for read events and ignore them. */ - fds[0].events = #ifdef __APPLE__ - POLLRDNORM + POLLRDNORM, #else - 0 + 0, #endif - ; + }, + }; + auto count = poll(fds, 1, -1); if (count == -1) { if (errno == EINTR || errno == EAGAIN)