Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Kill the running program

Shell Programming and Scripting

Thread Tools Search this Thread Display Modes
Old Unix and Linux 12-26-2008   -   Original Discussion by akhtar.bhat
akhtar.bhat's Unix or Linux Image
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   -   Original Discussion by akhtar.bhat
matrixmadhan's Unix or Linux Image
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
Join Date: Mar 2005
Last Activity: 10 January 2017, 8:10 AM EST
Location: classification algos
Posts: 3,215
Thanks: 19
Thanked 31 Times in 28 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

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:14 PM.