What is a <defunct> process, and why doesn't it get killed?
The chrome browser was not responsive and I tried to kill it, but instead of disappearing the process had <defunct>
at its right, and didn't get killed:
What is <defunct>
for a process and why it doesn't it get killed?
From your output we see a "defunct", which means the process has either completed its task or has been corrupted or killed, but its child processes are still running or these parent process is monitoring its child process. To kill this kind of process, kill -9 PID doesn't work. You can try to kill them with this command but it will show this again and again.
Determine which is the parent process of this defunct process and kill it. To know this run the command:
$ ps -ef | grep defunct
UID PID PPID C STIME TTY TIME CMD
1000 637 27872 0 Oct12 ? 00:00:04 [chrome] <defunct>
1000 1808 1777 0 Oct04 ? 00:00:00 [zeitgeist-datah] <defunct>
Then kill -9 637 27872
, then verify the defunct process is gone by ps -ef | grep defunct
.
Manual page ps(1) says:
Processes marked
<defunct>
are dead processes (so-called "zombies") that remain because their parent has not destroyed them properly. These processes will be destroyed byinit(8)
if the parent process exits.
You can't kill it because it is already dead. The only thing left is an entry in the process table:
On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table. This entry is still needed to allow the parent process to read its child's exit status.
There is no harm in letting such processes be unless there are many of them. Zombie is eventually reaped by its parent (by calling wait(2)
). If original parent hasn't reaped it before its own exit then init
process (pid == 1
) does it at some later time. Zombie Process is just:
A process that has terminated and that is deleted when its exit status has been reported to another process which is waiting for that process to terminate.
expanding on Paddington's answer..
From your output we see a defunct, which means this child process has either completed its task or has been corrupted or killed. Its parent process is still running and has not noticed its dead child.
kill -9 PID
won't work (already dead).
To determine the parent of this child process, run this command:
ps -ef | grep defunct
UID PID **PPID** C STIME TTY TIME CMD
1000 637 27872 0 Oct12 ? 00:00:04 [chrome] <defunct>
See who the parent is: ps ax | grep 27872
If you want you can kill the parent, and the defunct will go away.
kill -9 27872
see Jfs answer for a more technical reasoning.
I accidently create <defunct>
processes by
- starting them from the terminal and
- then putting them into the background by accident (Ctrl+Z) and
- somehow terminating the programm.
Solution is to try the command fg
in every open terminal window.
Then the defunct processes disappear.