Welcome to WebmasterWorld Guest from 54.161.25.142

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Kill running program from webinterface

     
11:14 pm on Aug 31, 2009 (gmt 0)

10+ Year Member



Hi guys, how can I stop/kill a program that I started from my webinterface when it is running and I need to stop it?

Ton

1:25 am on Sep 1, 2009 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.)

 

Featured Threads

Hot Threads This Week

Hot Threads This Month