title: limit execution time of shell_exec
body: <p>I have an exe file which has the following code:</p>
  <p><strong>while(1)</strong></p>
  <p><strong>printf(&quot;hello\n&quot;);</strong></p>
  <p>I'm executing this exe through php using shell_exec</p>
  <p><strong>$output = shell_exec('C:/Users/thekosmix/Desktop/hello.exe 2&gt;&amp;1');</strong></p>
  <p><strong>echo $output;</strong></p>
  <p>now the script is executing for very long time untill i kill the process from task manager and it gives fatal error:</p>
  <p><strong>(Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 133693440 bytes) in C:\xampp\htdocs\shell\index.php on line 7)</strong></p>
  <p>I want the script (or this function) to run for a given time duration and print whatever output is generated during the time-duration not any fatal error. set_time_limit() is also not solving the problem.</p>