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 #include #include #include @@ -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; + struct pollfd fds; - fds[0].fd = libevdev_get_fd(dev); - fds[0].events = POLLIN; + fds.fd = libevdev_get_fd(dev); + fds.events = POLLIN; - sigemptyset(&mask); - sigaddset(&mask, SIGINT); - fds[1].fd = signalfd(-1, &mask, SFD_NONBLOCK); - fds[1].events = POLLIN; + signal(SIGINT, signal_handler); - sigprocmask(SIG_BLOCK, &mask, NULL); - - while (poll(fds, 2, -1)) { + while (poll(&fds, 1, -1)) { struct input_event ev; int rc; - if (fds[1].revents) + if (signalled) break; do { diff --git a/tools/touchpad-edge-detector.c b/tools/touchpad-edge-detector.c index 8b16cd7..7727cad 100644 --- a/tools/touchpad-edge-detector.c +++ b/tools/touchpad-edge-detector.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include #include #include @@ -41,6 +40,8 @@ #define min(a, b) (((a) < (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b)) +static int signalled = 0; + static int usage(void) { printf("Usage: %s 12x34 /dev/input/eventX\n", program_invocation_short_name); @@ -102,26 +103,26 @@ handle_event(struct dimensions *d, const struct input_event *ev) { return 0; } +static void +signal_handler(__attribute__((__unused__)) int signal) +{ + signalled++; +} + static int mainloop(struct libevdev *dev, struct dimensions *dim) { - struct pollfd fds[2]; - sigset_t mask; + struct pollfd fds; - fds[0].fd = libevdev_get_fd(dev); - fds[0].events = POLLIN; + fds.fd = libevdev_get_fd(dev); + fds.events = POLLIN; - sigemptyset(&mask); - sigaddset(&mask, SIGINT); - fds[1].fd = signalfd(-1, &mask, SFD_NONBLOCK); - fds[1].events = POLLIN; + signal(SIGINT, signal_handler); - sigprocmask(SIG_BLOCK, &mask, NULL); - - while (poll(fds, 2, -1)) { + while (poll(&fds, 1, -1)) { struct input_event ev; int rc; - if (fds[1].revents) + if (signalled) break; do {