From eee582e7951fa8e328d1fcdfcff940254070ccba Mon Sep 17 00:00:00 2001 From: nihilix-melix <74101100+nihilix-melix@users.noreply.github.com> Date: Fri, 27 Nov 2020 11:21:22 +0100 Subject: [PATCH] Update logind-button.c --- src/login/logind-button.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/login/logind-button.c b/src/login/logind-button.c index f9e6e43b81..60de2dccad 100644 --- a/src/login/logind-button.c +++ b/src/login/logind-button.c @@ -13,6 +13,7 @@ #include "missing_input.h" #include "string-util.h" #include "util.h" +#include "async.h" #define CONST_MAX5(a, b, c, d, e) CONST_MAX(CONST_MAX(a, b), CONST_MAX(CONST_MAX(c, d), e)) @@ -63,7 +64,7 @@ void button_free(Button *b) { /* If the device has been unplugged close() returns * ENODEV, let's ignore this, hence we don't use * safe_close() */ - (void) close(b->fd); + (void) asynchronous_close(b->fd); free(b->name); free(b->seat); @@ -344,10 +345,12 @@ int button_open(Button *b) { r = button_suitable(fd); if (r < 0) return log_warning_errno(r, "Failed to determine whether input device %s is relevant to us: %m", p); - if (r == 0) + if (r == 0) { + b->fd = TAKE_FD(fd); return log_debug_errno(SYNTHETIC_ERRNO(EADDRNOTAVAIL), "Device %s does not expose keys or switches relevant to us, ignoring.", p); - + } + if (ioctl(fd, EVIOCGNAME(sizeof name), name) < 0) return log_error_errno(errno, "Failed to get input name for %s: %m", p);