aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGreg Kurz <gkurz@fr.ibm.com>2012-01-05 23:34:46 +0100
committerDaniel Lezcano <daniel.lezcano@free.fr>2012-01-05 23:34:46 +0100
commit65b6a86da2a65a34f6acc32420e90d31aab1732e (patch)
treeae5b08477bee69aff2656d7ce6d4ae8b059b0f30 /src
parentubuntu template: use -updates and -security (v3) (diff)
downloadlxc-65b6a86da2a65a34f6acc32420e90d31aab1732e.tar.gz
lxc-65b6a86da2a65a34f6acc32420e90d31aab1732e.tar.bz2
lxc-65b6a86da2a65a34f6acc32420e90d31aab1732e.zip
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 <gkurz@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/lxc/lxc_monitor.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index 1da0906..3802d2e 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;