homepage Welcome to WebmasterWorld Guest from 54.205.188.59
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Kill running program from webinterface
parrot




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

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

 

rocknbil




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved