title: Equivalent of select or poll in bash
body: <p>Is it possible to do selects or polls on file descriptors in bash? The essence of what I'm trying to do is this:</p>
  
  <pre><code>mkfifo fifo
  exec 3&lt;fifo
  PROMPT_COMMAND="while read -t 0 line; do echo \$line; done &lt;&amp;3"
  </code></pre>
  
  <p>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.</p>
  
  <p><code>-t 1</code> works like a charm, but that forces a one second delay at every prompt, which is not what I want.</p>
  
  <p>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.</p>
  
  <p>Any ideas?</p>