title: exec() with timeout
body: <p>I'm looking for a way to run a PHP process with a timeout. Currently I'm simply using <a href="http://php.net/function.exec" rel="noreferrer"><code>exec()</code></a>, but it does not provide a timeout option.</p>
  
  <p>What I also tried is opening the process using <a href="http://php.net/proc_open" rel="noreferrer"><code>proc_open()</code></a> and using <a href="http://php.net/stream_set_timeout" rel="noreferrer"><code>stream_set_timeout()</code></a> on the resulting pipe, but that didn't work either.</p>
  
  <p>So, is there any way to run a command (a PHP command to be precise) with a timeout? (PS: This is for cases where the <code>max_execution_time</code> limit fails, so no need to suggest that.)</p>
  
  <p>(By the way, I also need to retrieve the return code of the process.)</p>