mirror of
https://github.com/NixOS/nix
synced 2025-06-25 23:11:16 +02:00
MonitorFdHup
: Cleanup a bit with designated initializers
(cherry picked from commit d028bb4c4a
)
This commit is contained in:
parent
709e228589
commit
1a461baee1
1 changed files with 9 additions and 6 deletions
|
@ -25,19 +25,22 @@ 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];
|
struct pollfd fds[1] = {
|
||||||
fds[0].fd = fd;
|
{
|
||||||
|
.fd = fd,
|
||||||
|
.events =
|
||||||
/* Polling for no specific events (i.e. just waiting
|
/* Polling for no specific events (i.e. just waiting
|
||||||
for an error/hangup) doesn't work on macOS
|
for an error/hangup) doesn't work on macOS
|
||||||
anymore. So wait for read events and ignore
|
anymore. So wait for read events and ignore
|
||||||
them. */
|
them. */
|
||||||
fds[0].events =
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
POLLRDNORM
|
POLLRDNORM,
|
||||||
#else
|
#else
|
||||||
0
|
0,
|
||||||
#endif
|
#endif
|
||||||
;
|
},
|
||||||
|
};
|
||||||
|
|
||||||
auto count = poll(fds, 1, -1);
|
auto count = poll(fds, 1, -1);
|
||||||
if (count == -1) {
|
if (count == -1) {
|
||||||
if (errno == EINTR || errno == EAGAIN)
|
if (errno == EINTR || errno == EAGAIN)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue