title: Real max_execution_time for PHP on linux
body: <p><a href="http://php.net/manual/en/function.set-time-limit.php" rel="noreferrer">According to the documentation:</a></p>
  <pre><code>max_execution_time only affect the execution time of the script itself. 
  Any time spent on activity that happens outside the execution of the script
  such as system calls using system(), stream operations, database queries, etc.
  is not included when determining the maximum time that the script has been running.
  This is not true on Windows where the measured time is real.
  </code></pre>
  <p>This is confirmed by testing:</p>
  <p><strong>Will not time out</strong></p>
  <pre><code>&lt;?php
  set_time_limit(5);
  $sql = mysqli_connect('localhost','root','root','mysql');
  $query = &quot;SELECT SLEEP(10) FROM mysql.user;&quot;;
  $sql-&gt;query($query) or die($query.'&lt;br /&gt;'.$sql-&gt;error);
  echo &quot;You got the page&quot;;
  </code></pre>
  <p><strong>Will time out</strong></p>
  <pre><code>&lt;?php
  set_time_limit(5);
  while (true) {
    // do nothing
  }
  echo &quot;You got the page&quot;;
  </code></pre>
  <p>Our problem is that we really would like PHP to timeout, regardless of what it is doing, after a given amount of time (as we don't want to keep resources busy if we know we've failed delivering a page in an acceptable amount of time, like 10 seconds). We know we can play with settings such as the <a href="http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_wait_timeout" rel="noreferrer">MySQL wait_timeout</a> for the SQL queries, but the page timeout will depend on the number of queries that are executed.</p>
  <p>Some people have tried to come up with <a href="http://php.net/manual/en/function.set-time-limit.php#105569" rel="noreferrer">workarounds</a> and it doesn't seem implementable.</p>
  <p><strong>Q: Is there an easy way to get a real <code>PHP max_execution_time</code> on linux, or are we better timing out elsewhere, such as <code>Apache</code> level?</strong></p>