Commit 65b6a86d by Greg Kurz Committed by Daniel Lezcano

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: 's avatarGreg Kurz <gkurz@fr.ibm.com> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 15da01b3
...@@ -84,6 +84,8 @@ int main(int argc, char *argv[]) ...@@ -84,6 +84,8 @@ int main(int argc, char *argv[])
if (fd < 0) if (fd < 0)
return -1; return -1;
setlinebuf(stdout);
for (;;) { for (;;) {
if (lxc_monitor_read(fd, &msg) < 0) if (lxc_monitor_read(fd, &msg) < 0)
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment