title: C++ application collapsing after some hours
body: <p>i have an application written in C++ that uses opencv 2.0, curl and a opensurf library. First a PHP script (cron.php) calls proc_open and calls the C++ application (called icomparer). When it finishes processing N images returns groups saying which images are the same, after that the script uses:</p>
  
  <pre><code>shell_exec('php cron.php &gt; /dev/null 2&gt;&amp;1 &amp;');  
  die;
  </code></pre>
  
  <p>And starts again. Well, after 800 or 900 iterates my icomparer starts breaking. The system don't lets me create more files, in icomparer and in the php script.</p>
  
  <pre><code>proc_open(): unable to create pipe Too many open files (2)
  shell_exec(): Unable to execute 'php cron.php &gt; /dev/null 2&gt;&amp;1 &amp;'
  </code></pre>
  
  <p>And curl fails too:</p>
  
  <pre><code>couldn't resolve host name (6)
  </code></pre>
  
  <p>Everything crashes. I think that i'm doing something wrong, for example, I dunno if starting another PHP process from a PHP process release resources.</p>
  
  <p>In "icomparer" I'm closing all opened files. Maybe not releasing all mutex with mutex_destroy... but in each iterator the c++ application is closed, I think that all stuff is released right?</p>
  
  <p>What I have to watch for? I have tried monitoring opened files with stof.</p>
  
  <hr>
  
  <ul>
  <li>Php 5.2</li>
  <li>Centos 5.X</li>
  <li>1 GB ram</li>
  <li>120 gb hard disk (4% used)</li>
  <li>4 x intel xeon</li>
  <li>Is a VPS (machine has 16 gb ram)</li>
  <li>The process opens 10 threads and joins them.</li>
  </ul>