Edit: Just realized you may not need a web-based kill. To do this get to a command line, type
ps aux
The current processes will display. Locate the process id associated with your web process, then type
kill [process id]
---------------------------------------
If you need a kill switch in the web interface . . . . .
You can get the current process id using fork() (child process, anyway) or ps aux; however you do it, you would assign the pid to a variable then output a link to the kill process, something like
<a href="yourscript.cgi?kill_pid=1234">Kill process 1234</a>
Then when clicked, decode the input and execute:
$stop_msg = `kill $pid`;
$stop_msg = ($stop_msg ne '')?$stop_msg:'No server message (successful)';
$progress_msg = qq¦<p>The process has been terminated with the following message from the server: $stop_msg.</p>\n¦;
print "content-type: text/html\n\n";
print $progress_msg;
I have a system for large file processing that takes significant time; I initiate the process, which forks the intensive process as the child. The parent process redirects to a page with an iframe that is on 5 second refresh. The iframe outputs the progress of the child process and contains the kill link, so once the process is complete, the kill link disappears (because the child process is now dead.)