chiark / gitweb /
busctl: exit cleanly when the bus connection is severed
authorLennart Poettering <lennart@poettering.net>
Wed, 7 Jan 2015 19:42:14 +0000 (20:42 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 7 Jan 2015 19:42:14 +0000 (20:42 +0100)
src/libsystemd/sd-bus/busctl.c

index c9eeb91..c0d51e0 100644 (file)
@@ -1127,6 +1127,8 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
                         return log_error_errno(r, "Failed to add match: %m");
         }
 
+        log_info("Monitoring bus message stream.");
+
         for (;;) {
                 _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
 
@@ -1136,6 +1138,12 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
 
                 if (m) {
                         dump(m, stdout);
+
+                        if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected") > 0) {
+                                log_info("Connection terminated, exiting.");
+                                return 0;
+                        }
+
                         continue;
                 }