]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
stdio-bridge: use ERRNO_IS_DISCONNECT() to detect disconnects
authorLennart Poettering <lennart@poettering.net>
Tue, 19 Mar 2019 12:02:21 +0000 (13:02 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 19 Mar 2019 14:29:44 +0000 (15:29 +0100)
Let's use the macro we already have to make this safer. Moreover log
about all other errors.

src/stdio-bridge/stdio-bridge.c

index 7060897ab7b5a130d6154aa2ca089f8362271191..1767515e3e430a5233a91ed5b9b9e0b339ed6a3c 100644 (file)
@@ -14,6 +14,7 @@
 #include "build.h"
 #include "bus-internal.h"
 #include "bus-util.h"
+#include "errno-util.h"
 #include "log.h"
 #include "main-func.h"
 #include "util.h"
@@ -187,9 +188,13 @@ static int run(int argc, char *argv[]) {
                         continue;
 
                 r = sd_bus_process(b, &m);
-                if (r < 0)
+                if (r < 0) {
                         /* treat 'connection reset by peer' as clean exit condition */
-                        return r == -ECONNRESET ? 0 : r;
+                        if (ERRNO_IS_DISCONNECT(r))
+                                return 0;
+
+                        return log_error_errno(r, "Failed to process bus: %m");
+                }
 
                 if (m) {
                         r = sd_bus_send(a, m, NULL);