summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornihilix-melix <74101100+nihilix-melix@users.noreply.github.com>2020-11-27 11:21:22 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-12-10 17:39:17 +0100
commitb6a663def6bb18edd7c4f4f8d1bebf60c9be5a68 (patch)
tree5708c70e94016d7154875a1abdf0ce44aa61e64c
parent9a14b1ddea05f35734f35b5311fdc1f0280e5552 (diff)
downloadsystemd-b6a663def6bb18edd7c4f4f8d1bebf60c9be5a68.tar.gz
Update logind-button.c
(cherry picked from commit eee582e7951fa8e328d1fcdfcff940254070ccba)
-rw-r--r--src/login/logind-button.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 9ec235a170..0706186450 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_MAX4(a, b, c, d) CONST_MAX(CONST_MAX(a, b), CONST_MAX(c, d))
@@ -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);
@@ -329,10 +330,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);