Daniel Barrett wrote:
I have a MediaWiki extension that invokes a Windows command-line program (gnuplot.exe) to do some processing. If the MediaWiki user clicks the browser "stop" button in the middle of processing, or closes the browser, the external program does not die. It hangs around until you eventually restart Apache.
What is the proper way to ensure that the external program is killed when the user clicks the browser's stop button, or closes the browser? Is this possible?
Specifically, my extension invokes code from the GNUplot extension (http://meta.wikimedia.org/wiki/Gnuplot):
require_once("gnuplot.php"); ... $output = renderGnuplot($gnuplotSrcString);
renderGnuplot() does a shell_exec().
I suppose "timing out" would be an OK solution (say, after 1 minute).
DanB
That's more a php bug on windows. (Maybe it's fixed on newer versions?) From suggestion at http://www.php.net/manual/en/language.operators.execution.php#21208 you could use $abort = ignore_user_abort(true); shell_exec() ignore_user_abort($abort);