summaryrefslogtreecommitdiff
path: root/tools/mouse-dpi-tool.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mouse-dpi-tool.c')
-rw-r--r--tools/mouse-dpi-tool.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/tools/mouse-dpi-tool.c b/tools/mouse-dpi-tool.c
index 9961f3a..911f61e 100644
--- a/tools/mouse-dpi-tool.c
+++ b/tools/mouse-dpi-tool.c
@@ -23,7 +23,6 @@
#include "config.h"
-#include <sys/signalfd.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -40,6 +39,8 @@
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
+static int signalled = 0;
+
struct measurements {
int distance;
double max_frequency;
@@ -138,26 +139,26 @@ handle_event(struct measurements *m, const struct input_event *ev)
return 0;
}
+static void
+signal_handler(__attribute__((__unused__)) int signal)
+{
+ signalled++;
+}
+
static int
mainloop(struct libevdev *dev, struct measurements *m) {
- struct pollfd fds[2];
- sigset_t mask;
-
- fds[0].fd = libevdev_get_fd(dev);
- fds[0].events = POLLIN;
+ struct pollfd fds;
- sigemptyset(&mask);
- sigaddset(&mask, SIGINT);
- fds[1].fd = signalfd(-1, &mask, SFD_NONBLOCK);
- fds[1].events = POLLIN;
+ fds.fd = libevdev_get_fd(dev);
+ fds.events = POLLIN;
- sigprocmask(SIG_BLOCK, &mask, NULL);
+ signal(SIGINT, signal_handler);
- while (poll(fds, 2, -1)) {
+ while (poll(&fds, 1, -1)) {
struct input_event ev;
int rc;
- if (fds[1].revents)
+ if (signalled)
break;
do {