title: Bash redirection: named pipes and EOF
body: <p>Take the following code:</p>
  
  <pre><code>rm -f pipe
  mkfifo pipe
  
  foo () {
      echo 1
      sleep 1
      echo 2
  }
  
  #1
  exec 3&lt; &lt;(foo &amp;)
  cat &lt;&amp;3 # works
  
  #2
  foo &gt;pipe &amp;
  cat &lt;pipe # works
  
  #3
  exec 3&lt;&gt;pipe
  foo &gt;&amp;3 &amp;
  cat &lt;&amp;3 # hangs
  
  #4 -- update: this is the correct approach for what I want to do
  foo &gt;pipe &amp;
  exec 3&lt;pipe
  rm pipe
  cat &lt;&amp;3 # works
  </code></pre>
  
  <p>Why does approach #3 hang, while others do not? Is there a way to make approach #3 not hang?</p>
  
  <p>Rationale: I wish to use quasi-unnamed pipes to connect several asynchronously running subprocesses, for this I need to delete the pipe after making a file descriptor point to it:</p>
  
  <pre><code>mkfifo pipe
  exec {fd}&lt;&gt;pipe
  rm pipe
  # use &amp;$fd only
  </code></pre>