title: PHP shell_exec - how to terminate the process if the connection is closed?
body: <p>I have a working php script using shell_exec to execute an external program that take about 30 seconds to complete.
  Problem is that if an user close the browser or the connection is closed for some reason the program executed with shell_exec continue to run for nothing, since it's output can't be sent to the user anymore.</p>
  
  <p>Is there a way to kill this process as soon as the connection is closed?</p>
  
  <p>Thank you for your help.</p>