busctl: flush stdout after dumping data
authorDavid Herrmann <dh.herrmann@gmail.com>
Sat, 4 Jul 2015 10:11:22 +0000 (12:11 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Sat, 4 Jul 2015 10:23:39 +0000 (12:23 +0200)
Running `busctl monitor` currently buffers data for several seconds /
kilobytes before writing stdout. This is highly confusing if you dump in a
file, ^C busctl and then end up with a file with data of the last few
_seconds_ missing.

Fix this by explicitly flushing after each signal.

src/libsystemd/sd-bus/busctl.c

index 39caa4e..5011c27 100644 (file)
@@ -1137,6 +1137,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
 
                 if (m) {
                         dump(m, stdout);
+                        fflush(stdout);
 
                         if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected") > 0) {
                                 log_info("Connection terminated, exiting.");