diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-01-07 20:42:14 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-01-07 20:42:14 +0100 |
commit | 92d66625794057081046f051f7564e0789de0ace (patch) | |
tree | 89d554e242dde9a2e74c360af886aec8ff05e14e /src/libsystemd | |
parent | 52cd587789b9452e6e7d5f2f9b2ea652f9ad036e (diff) |
busctl: exit cleanly when the bus connection is severed
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-bus/busctl.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c index c9eeb91b0c..c0d51e06a3 100644 --- a/src/libsystemd/sd-bus/busctl.c +++ b/src/libsystemd/sd-bus/busctl.c @@ -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; } |