title: "too many open files" error after deleting many files
body: <p>My program creates a log file every 10 seconds in a specified directory. Then in a different thread, it iterates the files in that directory. If the file has content it compresses it and uploads it to external storage, if the file is empty, it deletes it. After the program runs for a while I get an error <code>"too many open files" (gzopen failed, errno = 24)</code>. </p>
  
  <p>When I looked inside <code>/proc/&lt;pid&gt;/fd</code> I see many broken links to files in the same directory where the logs are created and the word <code>(deleted)</code> next to the link. </p>
  
  <p>Any idea what am I doing wrong? I checked the return values in both threads, of the <code>close</code> function (in the thread which writes the logs), and in the <code>boost::filesystem::remove</code> (the thread which compresses and uploads the non empty log files and deletes empty log files). All the return values are zero while the list of the <code>(deleted)</code> links gets longer buy 1 every 10 seconds. </p>
  
  <p>I think this problem never happened to me on 32 bits but recently I moved to 64 bits and now I got this surprise.</p>