Skip to contentSkip to conversation

iio: event_monitor: Flush output on event

PATCH In review Zach DeCook 2 participants 2 messages Dec 8, 2021 – Dec 16, 2021 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: event_monitor: Flush output on event

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.

---
 tools/iio/iio_event_monitor.c | 1 +
 1 file changed, 1 insertion(+)
tools/iio/iio_event_monitor.c +1 -0
index 0076437f6..b94a16ba5 100644
@@ -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 */
Signature · 1 line
2.34.0
#1 lore raw
Quoted 9 lines · On Wed, 8 Dec 2021 16:48:08 -0500 Zach DeCook <[email protected]> wrote:

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.

Seems sensible to me.

Applied to the togreg branch of iio.git and pushed out as testing for 0-day to poke at it (possibly - no idea what it does with tools patches :)

Jonathan

Quoted 16 lines
---
 tools/iio/iio_event_monitor.c | 1 +
 1 file changed, 1 insertion(+)
tools/iio/iio_event_monitor.c +1 -0
index 0076437f6..b94a16ba5 100644
@@ -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 */