]> git.openfabrics.org - ~shefty/libibverbs.git/commitdiff
Force line-buffering in ibv_asyncwatch
authorHakon Bugge <Haakon.Bugge@sun.com>
Wed, 2 Jun 2010 17:01:10 +0000 (10:01 -0700)
committerRoland Dreier <rolandd@cisco.com>
Wed, 2 Jun 2010 17:01:10 +0000 (10:01 -0700)
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>
examples/asyncwatch.c

index e56b4dc9a28682537cd13533fee0319da335feec..5510a29b7f2063806e508d6b9ff0d3b0c28deef9 100644 (file)
@@ -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");