LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This 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
 
Thread Tools
Old 11-03-2009, 02:48 AM   #1
rockingb4u
LQ Newbie
 
Registered: Nov 2009
Posts: 9
Thanked: 0
internal working of kill command


[Log in to get rid of this advertisement]
i am working on kill command in linux,so i want to know how it works when it is called to kill some process,
how process is assigned with pid and which file of process does kill attacks to terminate it
windows_vista rockingb4u is offline     Reply With Quote
Old 11-03-2009, 02:57 AM   #2
Disillusionist
Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 825
Thanked: 48
Have you looked at the man page?

Code:
man kill
kill doesn't attack a file it sends a signal to the running process based on the process id that you supply to kill.
windows_vista Disillusionist is offline     Reply With Quote


Old 11-03-2009, 03:51 AM   #3
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA
Distribution: Debian Squeeze, SuSE 11.0, F8, F10, F11 x86_64
Posts: 1,130
Thanked: 16
Kill is a kernel based command. It tells the Linux kernel to terminate a certain process, based on pid. If you want to know exactly how the program works, there are some good books written about the Linux kernel internals. One of them is called, "Inside The Linux Kernel".
linuxdebian AwesomeMachine is offline     Reply With Quote


Old 11-03-2009, 11:16 AM   #4
rockingb4u
LQ Newbie
 
Registered: Nov 2009
Posts: 9
Thanked: 0

Original Poster
Quote:
Originally Posted by AwesomeMachine View Post
Kill is a kernel based command. It tells the Linux kernel to terminate a certain process, based on pid. If you want to know exactly how the program works, there are some good books written about the Linux kernel internals. One of them is called, "Inside The Linux Kernel".
how a process gets a pid no and who assign it and if i m shutting down my pc by a command init 6 then a command killall comes,can i shut down my pc without using killall command and how
windows_vista rockingb4u is offline     Reply With Quote


Old 11-03-2009, 11:38 AM   #5
r3sistance
Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 5.4, Mac OS 10.4 (tiger)
Posts: 648
Thanked: 37
What ever command you use to shutdown a system will generate a killall command as all processes need to be stopped before the system completely shuts itself down.

When a process starts it's assign a process ID via the system/kernel, you can find out the process ids currently active from the command 'ps aux' this will generate alot of output if you have alot of commands however so best used with the grep command but it's worth noting this command will display the grep process itself on top of what you are searching for.
windows_vista r3sistance is offline     Reply With Quote


Old 11-03-2009, 11:56 AM   #6
rockingb4u
LQ Newbie
 
Registered: Nov 2009
Posts: 9
Thanked: 0

Original Poster
Quote:
Originally Posted by r3sistance View Post
What ever command you use to shutdown a system will generate a killall command as all processes need to be stopped before the system completely shuts itself down.

When a process starts it's assign a process ID via the system/kernel, you can find out the process ids currently active from the command 'ps aux' this will generate alot of output if you have alot of commands however so best used with the grep command but it's worth noting this command will display the grep process itself on top of what you are searching for.
i want to kill some process,so can u suggest me that i should use the kill command login as root or i should make a user,i just want to check it
windows_vista rockingb4u is offline     Reply With Quote


Old 11-03-2009, 02:07 PM   #7
cantab
Member
 
Registered: Oct 2009
Distribution: Arch, Vector
Posts: 83
Thanked: 14
A normal user can kill the processes they own. A root user can kill any process. For example, if I do ps aux now, I get
Code:
$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
tw296     1723  0.0  0.1   3376   804 ?        Ss   16:13   0:00 /usr/sbin/famd
mpd       1733  2.9  2.2  55780 11508 ?        Ssl  16:13   4:52 /usr/bin/mpd /e
root      1745  0.0  0.9   8608  4804 ?        Ss   16:13   0:06 /usr/bin/slim
root      1747  4.8 11.0  66460 56624 tty7     Rs+  16:13   7:57 /usr/bin/X -nol
tw296     1784 10.8 19.8 303296 101792 ?       Sl   16:13  17:46 firefox
tw296     1795  0.5  4.7  54520 24548 ?        S    16:14   0:57 pidgin
tw296     2301  6.0  1.8  26556  9432 ?        S    18:57   0:00 lxterminal
(note that that output has been drastically trimmed, the whole thing is very long with many processes)

Logged in as tw296, I could stop pidgin with 'kill 1795', but I wouldn't be able to stop X with 'kill 1747', or mpd (a music player daemon) with 'kill 1733'. To kill mpd I could log in as mpd, to kill X I would have to log in as root, and could then kill pidgin, mpd, X, firefox, whatever.

Also, the kill command doesn't just kill things. It sends what are called signals to processes. The default is signal 15, TERM, which asks the process to quit. Some processes will autsave before quitting that way, while a totally nonresponsive process won't quit at all. 'kill -9' will send signal 9, KILL, which ends the process immediately.

The 'killall' command in Linux does not kill everything. In Linux killall kills processes by name, for example 'killall pidgin' would kill pidgin in the example above - in the event that two instances of pidgin were running it would kill them both.
linux cantab is offline     Reply With Quote


Old 11-03-2009, 02:46 PM   #8
rockingb4u
LQ Newbie
 
Registered: Nov 2009
Posts: 9
Thanked: 0

Original Poster
Quote:
Originally Posted by cantab View Post
A normal user can kill the processes they own. A root user can kill any process. For example, if I do ps aux now, I get
Code:
$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
tw296     1723  0.0  0.1   3376   804 ?        Ss   16:13   0:00 /usr/sbin/famd
mpd       1733  2.9  2.2  55780 11508 ?        Ssl  16:13   4:52 /usr/bin/mpd /e
root      1745  0.0  0.9   8608  4804 ?        Ss   16:13   0:06 /usr/bin/slim
root      1747  4.8 11.0  66460 56624 tty7     Rs+  16:13   7:57 /usr/bin/X -nol
tw296     1784 10.8 19.8 303296 101792 ?       Sl   16:13  17:46 firefox
tw296     1795  0.5  4.7  54520 24548 ?        S    16:14   0:57 pidgin
tw296     2301  6.0  1.8  26556  9432 ?        S    18:57   0:00 lxterminal
(note that that output has been drastically trimmed, the whole thing is very long with many processes)

Logged in as tw296, I could stop pidgin with 'kill 1795', but I wouldn't be able to stop X with 'kill 1747', or mpd (a music player daemon) with 'kill 1733'. To kill mpd I could log in as mpd, to kill X I would have to log in as root, and could then kill pidgin, mpd, X, firefox, whatever.

Also, the kill command doesn't just kill things. It sends what are called signals to processes. The default is signal 15, TERM, which asks the process to quit. Some processes will autsave before quitting that way, while a totally nonresponsive process won't quit at all. 'kill -9' will send signal 9, KILL, which ends the process immediately.

The 'killall' command in Linux does not kill everything. In Linux killall kills processes by name, for example 'killall pidgin' would kill pidgin in the example above - in the event that two instances of pidgin were running it would kill them both.
i have seen the surce code of kill command in c++,is there any source code in java and if i want to change the working of kill command or some more implementation i have to do ,so i have to do some changes in coding...sugest me
windows_vista rockingb4u is offline     Reply With Quote


Old 11-03-2009, 06:59 PM   #9
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 5.4
Posts: 7,435
Thanked: 326
Kernels & OSes generally are written in C and/or C++ (& assembler). Java requires JVM to run, so it can't be the OS itself.
windows_xp_2003 chrism01 is online now     Reply With Quote


Old 11-04-2009, 05:06 AM   #10
rockingb4u
LQ Newbie
 
Registered: Nov 2009
Posts: 9
Thanked: 0

Original Poster
Quote:
Originally Posted by chrism01 View Post
Kernels & OSes generally are written in C and/or C++ (& assembler). Java requires JVM to run, so it can't be the OS itself.
if i m installing something in linux,so by ps aux i will know its pid no after that if i m running that process and by using the kill command i dont want to terminate it but pause it for sometime and then resume it...
what are the commands for this and how it will works
windows_vista rockingb4u is offline     Reply With Quote


Old 11-04-2009, 11:21 AM   #11
rockingb4u
LQ Newbie
 
Registered: Nov 2009
Posts: 9
Thanked: 0

Original Poster
Quote:
Originally Posted by rockingb4u View Post
i am working on kill command in linux,so i want to know how it works when it is called to kill some process,
how process is assigned with pid and which file of process does kill attacks to terminate it
when process runs it provide with pid no by kernel,if i want dat it does not terminate it but pause for sometime and after that resume it....suggest me some commands for it....
windows_vista rockingb4u is offline     Reply With Quote


Old 11-04-2009, 12:20 PM   #12
cantab
Member
 
Registered: Oct 2009
Distribution: Arch, Vector
Posts: 83
Thanked: 14
You send it the STOP signal, using kill.

http://tombuntu.com/index.php/2007/1...linux-process/
linux cantab is offline     Reply With Quote


Old 11-05-2009, 05:07 AM   #13
rockingb4u
LQ Newbie
 
Registered: Nov 2009
Posts: 9
Thanked: 0

Original Poster
Quote:
Originally Posted by cantab View Post
You send it the STOP signal, using kill.

http://tombuntu.com/index.php/2007/1...linux-process/
if i m installing gcc, while installing in the middle can i pause it for sometime using kill stop command and how many files it download and after viewing resume it......
windows_xp_2003 rockingb4u is offline     Reply With Quote


Old 11-07-2009, 06:59 AM   #14
rockingb4u
LQ Newbie
 
Registered: Nov 2009
Posts: 9
Thanked: 0

Original Poster
Quote:
Originally Posted by cantab View Post
You send it the STOP signal, using kill.

http://tombuntu.com/index.php/2007/1...linux-process/
if i am transferring data from one pc to other pc through command scp,then
how we will pause the transferring in between ,so that i can see how much data is transfered....can we pause it through kill command and if not..suggest me the command
windows_vista rockingb4u is offline     Reply With Quote


Old 11-07-2009, 10:16 AM   #15
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,483
Thanked: 0
Quote:
Originally Posted by rockingb4u View Post
if i m installing gcc, while installing in the middle can i pause it for sometime using kill stop command and how many files it download and after viewing resume it......
The kill command would not details like how many files it has downloaded. Kill simply sends a signal to the running program.

What exactly are you trying to accomplish by reworking the kill command? It's possible that there may be an application that already has the functionality that you require.
windows_xp_2003 stickman is offline     Reply With Quote



Reply

Bookmarks


Thread Tools

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
kill command pulkitbajar Linux - Newbie 7 05-12-2009 08:19 PM
why we cannot kill process id 1 with command "kill -9 1" satyaredhat Linux - Newbie 7 03-11-2009 01:48 PM
kill command micro_xii Linux - Newbie 4 11-24-2006 09:48 AM
Kill command could not kill Kanaflloric Linux - General 11 08-22-2005 08:18 AM
The kill command tearinox Linux - Newbie 2 08-15-2003 05:40 PM


All times are GMT -5. The time now is 11:37 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration