Skip to content

Commit

Permalink
hyprctl: avoid using select()
Browse files Browse the repository at this point in the history
move to poll()

ref #6584
  • Loading branch information
vaxerski committed Jun 18, 2024
1 parent 236150b commit b98e087
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/debug/HyprCtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <sys/utsname.h>
#include <sys/un.h>
#include <unistd.h>
#include <sys/poll.h>

#include <sstream>
#include <string>
Expand Down Expand Up @@ -1784,13 +1785,17 @@ int hyprCtlFDTick(int fd, uint32_t mask, void* data) {

std::array<char, 1024> readBuffer;

fd_set fdset;
FD_ZERO(&fdset);
FD_SET(ACCEPTEDCONNECTION, &fdset);
timeval timeout = {.tv_sec = 0, .tv_usec = 5000};
auto success = select(ACCEPTEDCONNECTION + 1, &fdset, nullptr, nullptr, &timeout);
//
pollfd pollfds[1] = {
{
.fd = ACCEPTEDCONNECTION,
.events = POLLIN,
},
};

int ret = poll(pollfds, 1, 5000);

if (success <= 0) {
if (ret <= 0) {
close(ACCEPTEDCONNECTION);
return 0;
}
Expand Down

0 comments on commit b98e087

Please sign in to comment.