diff options
author | Kenny Levinsen <kl@kl.wtf> | 2021-02-27 18:24:54 +0100 |
---|---|---|
committer | Kenny Levinsen <kl@kl.wtf> | 2021-02-27 19:35:01 +0100 |
commit | 6cf751af2b0313bc9b78ea9e56dc72ec91325935 (patch) | |
tree | 38ecea89deced327a848bd9b99b449310b9122ba | |
parent | da3cbcc9436321e59b9e11fa8caa624e3d71ea35 (diff) |
logind: Fix return values from close_device/get_fd
-rw-r--r-- | libseat/backend/logind.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libseat/backend/logind.c b/libseat/backend/logind.c index 0ae95b1..c6f2aaf 100644 --- a/libseat/backend/logind.c +++ b/libseat/backend/logind.c @@ -151,7 +151,7 @@ static int close_device(struct libseat *base, int device_id) { sd_bus_error_free(&error); sd_bus_message_unref(msg); - return ret >= 0; + return ret < 0 ? -1 : 0; } static int switch_session(struct libseat *base, int s) { @@ -183,7 +183,13 @@ static int disable_seat(struct libseat *base) { static int get_fd(struct libseat *base) { struct backend_logind *backend = backend_logind_from_libseat_backend(base); - return sd_bus_get_fd(backend->bus); + int fd = sd_bus_get_fd(backend->bus); + if (fd >= 0) { + return fd; + } + + errno = -fd; + return -1; } static int poll_connection(struct backend_logind *backend, int timeout) { |