1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 19:01:16 +02:00

MonitorFdHup: introduce a num_fds variable

Better than just putting `1` in multiple spots.

(cherry picked from commit cb95791198)
This commit is contained in:
John Ericson 2025-03-23 18:21:20 -04:00 committed by Mergify
parent da213e8ee5
commit 2d792a1867

View file

@ -25,7 +25,8 @@ public:
thread = std::thread([fd]() { thread = std::thread([fd]() {
while (true) { while (true) {
/* Wait indefinitely until a POLLHUP occurs. */ /* Wait indefinitely until a POLLHUP occurs. */
struct pollfd fds[1] = { constexpr size_t num_fds = 1;
struct pollfd fds[num_fds] = {
{ {
.fd = fd, .fd = fd,
.events = .events =
@ -41,7 +42,7 @@ public:
}, },
}; };
auto count = poll(fds, 1, -1); auto count = poll(fds, num_fds, -1);
if (count == -1) { if (count == -1) {
if (errno == EINTR || errno == EAGAIN) if (errno == EINTR || errno == EAGAIN)
continue; continue;