On Mon, Nov 22, 2004 at 09:48:24AM -0000, Rahul wrote:
> Can any one tell me How to kill a Zombie / Defunct process . I
> searched a lot in net what I found was that a Zombie process cannot
> be killed . can a defunct process be killed . Help needed . Rahul
Dear Group,
Let me share some details about the topic.
command Kill means send a "signal" to a process please note the Signal
When we write kill -9 PID, that means Sending the signal 9 to the
corresponding PID, that is suppose to be received.
The signals are fully dependant on the System design Standards. Linux
currently support the following Signals,as per listed in nice table.
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE
9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
13) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD
18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN
22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO
30) SIGPWR 31) SIGSYS 33) SIGRTMIN 34) SIGRTMIN+1
35) SIGRTMIN+2 36) SIGRTMIN+3 37) SIGRTMIN+4 38) SIGRTMIN+5
39) SIGRTMIN+6 40) SIGRTMIN+7 41) SIGRTMIN+8 42) SIGRTMIN+9
43) SIGRTMIN+10 44) SIGRTMIN+11 45) SIGRTMIN+12 46) SIGRTMIN+13
47) SIGRTMIN+14 48) SIGRTMIN+15 49) SIGRTMAX-15 50) SIGRTMAX-14
51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10
55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6
59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX
So in the above command Kill -9,means we are actually sending SIGKILL
signal to the corresponding pid(Process id,since kernel interpert
every process by an uniq integer value), and not any prority level.
About SIGKILL:This is mainly for Termination.POSIX.1,SVR4,4.3BSD
support SIGKILL.but ANSI C wont.
for more information on signals please do refer the man pages.
$man 7 signal
About Program Termination.
-------------------------
Here the context is Zombie process. So let me have some ideas about
Process termination. Here I am not refering about fork().
There are three ways for a process to get teminated.
1)Normal Termination.
--------------------
a)Getting a return from the main(), is it equivalent to call exit.
b)In ANSI C calling exit via atexit,since ANSI does not deals with
file descriptors,multiple process and job control.
c)or by _exit POSIX standard.
2)Abnormal Termination.
----------------------
a)calling abort.
b)The process can generate signals itself or by the kernel,because
of some vital error in programs.
Note: Here the parent of the process can obtain the termination status
form either wait() or waitpid().
3)Ways of Abnormal Termination.
-----------------------------
As we know,every child process has a parent if fork() is called. So in
returning a termination status we can have 2 possible of abnormal
termination. It is either by
a)If parent process is terminated before child.
Here init become the parent process of any process whose parent
terminates.What happens is that the kernel goes through all active
process to see ifthe terminating process is the parent of any process
still exists. If so the parent process ID id of the still existing
process is changed to 1,ie the process id of init. Thus making every
process has a parent.
b)Child terminates before parent.
Please note here we are discussing abnormal termination. If a
child completely disappears, the parent wont able to fetch its
termination status.Here the kernel has to keep certain amount of
information from every terminating process,so that the information is
available when the parent of the terminating process calls wait() or
waitpid().The information comprising of Process ID,termination status
of the process,the amount of CPU time taken by the process. The
Kernel can discard all the memory used by the process and close all
open files.Here the process who is terminated but whose parent has not
yet waited for it is called a zombie process. ps command show is as
'Z'.
So last scenario. What happens when a process that has been
inheritedby init terminates? does it becomes Zombie?
"NO"
Because init is written in so that whateverone of its children
terminated init calls one of the wait function to fetch the
termination status. by doing this init prevents the system from being
clogged by zombies. When we say one of inits children we mean either a
process that init directly generates or a process whose parent has
terminated and has been inherited by init.
I think the picture is clear now. Please do correct me if I made a
wrong interpretations.
--
Rgds
$hyam
"Tomorrow do thy worst, I have lived today."
(_)
~$~
~