]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc: line buffered output for lxc-monitor
authorGreg Kurz <gkurz@fr.ibm.com>
Thu, 5 Jan 2012 22:34:46 +0000 (23:34 +0100)
committerDaniel Lezcano <daniel.lezcano@free.fr>
Thu, 5 Jan 2012 22:34:46 +0000 (23:34 +0100)
A typical usage is to start lxc-monitor in popen() and parse the ouput.
Unfortunately, glibc defaults to block buffering for pipes and you may
have to wait several lines before anything is written to stdout... this
prevent the use of lxc-monitor to implement automatons. Let's go line
buffered !

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lxc_monitor.c

index 1da090617e761a3b9e92a175afcde2c761e08781..3802d2e5e2b99295aeff2847ec527b1d1d9470f5 100644 (file)
@@ -84,6 +84,8 @@ int main(int argc, char *argv[])
        if (fd < 0)
                return -1;
 
+       setlinebuf(stdout);
+
        for (;;) {
                if (lxc_monitor_read(fd, &msg) < 0)
                        return -1;