LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-08-2007, 03:11 AM   #1
suhas!
Member
 
Registered: Mar 2007
Posts: 100

Rep: Reputation: 17
Different types of kill commands


Hi All,

I would like to know what are the different types of kill command in linux. i.e. kill, kill -0, kill -9, skill, pkill, killall, killproc, kill -SIGHUP, kill -HUP etc. What are their purpose and when to use it?

Kindly advise.
 
Old 08-08-2007, 03:53 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,276

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
See kill -l for a full list. All the kill command real does is send a signal to the target process(es). The other commands you list are variations on this basic theme -- read their man pages for more details. How the process responds depends on how (and if) it's set up to interpret that signal. The only signals processes can't have handlers for are SIGKILL (number 9, hence the infamous kill -9) and SIGSTOP (forcibly suspends process execution). Many of the other signals date back to days of yore when folks interacted with computers via teletypes and dial-in lines (e.g. SIGHUP used to mean that the terminal line had physically hung up, but now processes often interpret this to mean restart execution or reopen log files).

The only signals end users need to worry about are generally SIGINT, SIGKILL, SIGTSTP, and SIGSTOP. The first to kill a process (SIGKILL forcibly, without giving a process a chance to handle the signal, so it's not a good idea to do that unless you have no other choice), e.g. in most cases pressing CTRL+C sends SIGINT to the foreground process. Likewise the latter two stop a process (SIGSTOP forcibly). SIGTSTP is what CTRL+Z sends top suspend a process, for example.

So it's a little bit complicated ... kill sends a signal (which may or may not terminate the process). Within limits, what the process does with that signal can be defined by the program.

Fun facts: init cannot be killed, even with kill -9. Processes in state D (I/O wait) will not be signaled until their state changes, as it's unsafe to terminate processes with locks on I/O buffers.
 
Old 08-08-2007, 04:46 AM   #3
suhas!
Member
 
Registered: Mar 2007
Posts: 100

Original Poster
Rep: Reputation: 17
thnx btmiller, it was nice information.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What if 'kill -9' fails to kill a task? chii-chan Linux - Newbie 15 03-27-2013 04:47 PM
c preprocessor commands & return types(?) kpachopoulos Programming 4 12-06-2005 10:18 AM
how to use kill to kill a batch of processes with same name? dr_zayus69 Linux - Software 2 09-03-2005 07:35 PM
cannot kill process (kill -9 does not work) mazer13a Linux - General 1 05-27-2005 03:32 PM
Commands (jobs and kill) xviddivxoggmp3 Linux - General 2 08-01-2004 10:42 PM


All times are GMT -5. The time now is 02:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration