Unix/Linux Go Back    

Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Kill the running program

Shell Programming and Scripting

Closed Linux or Unix Question    
Thread Tools Search this Thread Display Modes
Old Unix and Linux 12-26-2008
akhtar.bhat akhtar.bhat is offline
Registered User
Join Date: Nov 2008
Last Activity: 2 November 2009, 2:28 AM EST
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Unix or Linux Question Kill the running program

Dear All,

I have a script which after executing is not stoping when i press ctrl+c.
Now i want to Append the script in such a way when i press ctrl+c while execution of the program it should take it as arguements and should kill the script/running program forcefully.

I know the command to kill the the program Forcefully (kill -9 `ps -a | grep "ping_script" | awk '{print $1}'` )

Please help me to get out of this problem.
Advance Thanks,
Akhtar Bhat.
Sponsored Links
Old Unix and Linux 12-26-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
Join Date: Mar 2005
Last Activity: 22 November 2015, 3:48 AM EST
Location: classification algos
Posts: 3,206
Thanks: 19
Thanked 30 Times in 27 Posts
Here is an example to trap INT signal ( Ctrl - C )

  echo "-- signal() --"
  echo "sleeping"
  sleep 1

trap signal INT

while :
  echo "here"
  sleep 1

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Trying to kill a program via help command. TiznaraN Shell Programming and Scripting 5 04-22-2008 12:57 PM
kill multiple instances of the same program ipzig Shell Programming and Scripting 12 12-17-2007 01:42 AM
kill textrdit program jeter Programming 6 06-07-2006 09:12 AM
C program to kill root processes TioTony Programming 8 07-24-2003 11:16 PM

All times are GMT -4. The time now is 03:58 AM.