title: Bash running out of File Descriptors
body: <p>I was working on a project, and I want to contribute with the solution I found:</p>
  
  <p>The code is of the kind:</p>
  
  <pre><code>while true
  do
       while read VAR
       do
          ......
       done &lt; &lt;(find ........ | sort)
       sleep 3
  done
  </code></pre>
  
  <p>The errors in the log where:</p>
  
  <pre><code>/dir/script.bin: redirection error: cannot duplicate fd: Too many open files
  /dir/script.bin: cannot make pipe for process substitution: Too many open files
  /dir/script.bin: line 26: &lt;(find "${DIRVAR}" -type f -name '*.pdf' | sort): Too many open files
  find: `/somedirtofind': Too many open files
  /dir/script.bin: cannot make pipe for process substitution: Too many open files
  /dir/script.bin: cannot make pipe for process substitution: Too many open files
  /dir/script.bin: line 26: &lt;(find "${DIRVAR}" -type f -name '*.pdf' | sort): ambiguous redirect
  </code></pre>
  
  <p>I noticed with command:</p>
  
  <p><code>ls -l /proc/3657(pid here)/fd</code> that the file descriptors were constantly increasing.</p>
  
  <p>Using Debian 7, GNU bash, version 4.2.37(1)-release (i486-pc-linux-gnu)</p>