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
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);
Thanks! I'll report back on whether this worked or not. So far it's done no harm....
DanB
-----Original Message----- Platonides wrote:
$abort = ignore_user_abort(true); shell_exec() ignore_user_abort($abort);
Unfortunately this did not prevent gnuplot.exe from hanging. I have also noticed latex.exe hanging in the same way at times.
DanB
-----Original Message----- From: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] On Behalf Of Daniel Barrett Sent: Wednesday, November 14, 2007 3:11 PM To: MediaWiki announcements and site admin list Subject: Re: [Mediawiki-l] Properly killing an invoked external program?
Thanks! I'll report back on whether this worked or not. So far it's done no harm....
DanB
-----Original Message----- Platonides wrote:
$abort = ignore_user_abort(true); shell_exec() ignore_user_abort($abort);
mediawiki-l@lists.wikimedia.org