Equivalent to selection or polling in bash

Is it possible to make selections or polls in file descriptors in bash? The essence of what I'm trying to do is this:

mkfifo fifo
exec 3<fifo
PROMPT_COMMAND="while read -t 0 line; do echo \$line; done <&3"

exec must maintain an open pipe (otherwise it will be closed at the end of each loop). Theoretically, this would output something entering the pipe before each invitation. However, this does not seem to work, since with -t0 it does not even try to read.

-t 1 It works like a charm, but it makes every second hold up one second, which I don’t want.

It would be optimal to make a choice with a .2 second timeout (if I execute a command that, in turn, forces something to write to the channel, there should be a slight delay, since I work with asynchronous messages), and with this delay I can live. A zero timeout will probably be fine, then I just create a program for the delay in subseconds.

Any ideas?

+5
source share
2 answers

I came across this today and it actually solves my problem pretty elegantly. screenallows you to split the current terminal window, where I can reduce one part of the window to several lines, where I save my input, and just cat fifoin another part of the window.

, ( -).

+1

:

$ > tail -f fifo

('-s'), -max-unchanged-stats ..

0

All Articles