From 2d792a18679409e145a013ddfd9740b694f21ede Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 23 Mar 2025 18:21:20 -0400 Subject: [PATCH] `MonitorFdHup`: introduce a `num_fds` variable Better than just putting `1` in multiple spots. (cherry picked from commit cb95791198019a5eb8996c4bc47b2ed10cf1ec41) --- src/libutil/unix/monitor-fd.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libutil/unix/monitor-fd.hh b/src/libutil/unix/monitor-fd.hh index 235a7db3c..ca1770342 100644 --- a/src/libutil/unix/monitor-fd.hh +++ b/src/libutil/unix/monitor-fd.hh @@ -25,7 +25,8 @@ public: thread = std::thread([fd]() { while (true) { /* Wait indefinitely until a POLLHUP occurs. */ - struct pollfd fds[1] = { + constexpr size_t num_fds = 1; + struct pollfd fds[num_fds] = { { .fd = fd, .events = @@ -41,7 +42,7 @@ public: }, }; - auto count = poll(fds, 1, -1); + auto count = poll(fds, num_fds, -1); if (count == -1) { if (errno == EINTR || errno == EAGAIN) continue;