Is it possible to do selects or polls on 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"
The exec is there to keep the pipe open (otherwise it would be closed at the end of each loop). In theory, this would output anything entering the pipe before each prompt. However, it doesn't seem to work, as with -t0 it doesn't even try to read.
-t 1
works like a charm, but that forces a one second delay at every prompt, which is not what I want.
Optimal would be to do a select with .2 seconds timeout (if i'm executing a command which in turn causes something to be written to the pipe, there's bound to be a short delay as I'm working with asynchronous messages), and that delay I can live with. Zero timeout would probably be ok, then I'll just create a program to have a subsecond delay.
Any ideas?