title: PHP: non blocking shell_exec WITH command output
body: <p>I'm using php's shell_exec to call bash files, system programs and Ksh files. </p>
  
  <p>One issue with shell_exec is that if you need the output, your web server will lock up (i.e., no new requests will be served) until the process is finished. A common trick is to set the process to run in the background (> /dev/null 2> /dev/null &amp;), but this of course, discards any output.</p>
  
  <p>I tried switching from apache to nginx thinking that this would solve my problem but the underlying issue appears to be how php's shell_exec blocks i/o. Even with nginx, shell_exec completely blocks any new http requests from completing.</p>
  
  <p>Does anyone know how to make system calls using php without locking up the server, while also capturing the output?</p>
  
  <p>I'm thinking of making a library that manages asynchronous system calls whereby the output can be retrieved later using Ajax.</p>
  
  <p>But I'd prefer not to go that route. Any suggestions?</p>