aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHakon Bugge <Haakon.Bugge@sun.com>2010-06-02 10:01:10 -0700
committerRoland Dreier <rolandd@cisco.com>2010-06-02 10:01:10 -0700
commit67ef5f59250b18067523084e9099e5e2fc6a5bf6 (patch)
treedfc44de4b6119c148d93eee9a38c084f29140345
parent6fa6bb3f28b3c08146718898a8a2ab8ae759b2b4 (diff)
downloadlibibverbs-67ef5f59250b18067523084e9099e5e2fc6a5bf6.tar.gz
Force line-buffering in ibv_asyncwatch
ibv_asyncwatch defaults to block-buffering when stdout is redirected to a file or pipe. Changing to line-buffered mode makes it more usable in scripted environments. Signed-off-by: Hakon Bugge <Haakon.Bugge@sun.com>
-rw-r--r--examples/asyncwatch.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/examples/asyncwatch.c b/examples/asyncwatch.c
index e56b4dc..5510a29 100644
--- a/examples/asyncwatch.c
+++ b/examples/asyncwatch.c
@@ -80,6 +80,9 @@ int main(int argc, char *argv[])
struct ibv_context *context;
struct ibv_async_event event;
+ /* Force line-buffering in case stdout is redirected */
+ setvbuf(stdout, NULL, _IOLBF, 0);
+
dev_list = ibv_get_device_list(NULL);
if (!dev_list) {
perror("Failed to get IB devices list");