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?
source
share