From: Greg Kurz Date: Thu, 5 Jan 2012 22:34:46 +0000 (+0100) Subject: lxc: line buffered output for lxc-monitor X-Git-Tag: lxc-0.8.0-rc2~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65b6a86da2a65a34f6acc32420e90d31aab1732e;p=thirdparty%2Flxc.git lxc: line buffered output for lxc-monitor 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 Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c index 1da090617..3802d2e5e 100644 --- a/src/lxc/lxc_monitor.c +++ b/src/lxc/lxc_monitor.c @@ -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;