iio: event_monitor: Flush output on event
authorZach DeCook <zachdecook@librem.one>
Wed, 8 Dec 2021 21:48:08 +0000 (16:48 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 16 Dec 2021 12:20:35 +0000 (12:20 +0000)
By flushing the output, iio_event_monitor can be more useful to programs
chained along with it.

  iio_event_monitor stk3310 | awk '/rising/{system("my_unlockscreen.sh")} /falling/{system("my_lockscreen.sh")}'

Without this flush, the above example would buffer a number of events,
then after a while run the lock/unlock scripts several times.

Signed-off-by: Zach DeCook <zachdecook@librem.one>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
tools/iio/iio_event_monitor.c

index 0076437..b94a16b 100644 (file)
@@ -279,6 +279,7 @@ static void print_event(struct iio_event_data *event)
                printf(", direction: %s", iio_ev_dir_text[dir]);
 
        printf("\n");
+       fflush(stdout);
 }
 
 /* Enable or disable events in sysfs if the knob is available */