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:

enter image description here

What is <defunct> for a process and why it doesn't it get killed?

  • 3
    The accepted answer mentions that "kill -9 PID don't work". It's partially true: in reality, NO kill will work. Besides, -9 should be used as a last resort. 99% of the time a default kill of the parent process will kill it AND reap all the children. A "default kill" is a SIGTERM (-15). I encourage fans of the -9 (SIGKILL) to read stackoverflow.com/questions/690415/… – Mike S Sep 1 '16 at 15:39
up vote 134 down vote accepted

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.

  • 11
    you can't kill "defunct" process. You only can speed up the deletion of its entry in a process table by killing its parent. – jfs Feb 27 '14 at 20:58
  • 41
    What if the ppid is 1 (init)? Suppose I'll just have to wait? – Luc May 6 '14 at 5:42
  • 5
    to automate the kill, you can do this, too (might need to change which bytes you're cutting from the output): ps -ef | grep defunct | grep -v grep | cut -b8-20 | xargs kill -9 – warren Jan 21 '15 at 19:34
  • 3
    @warren Thanks. You can also make that slightly shorter and (imo) simpler by not doing a second grep. Just change the first grep to grep [d]efunct or similar and it won't match itself. – Thor84no Jul 26 '16 at 11:35
  • 4
    @warren you can't kill a defunct process- even with a SIGKILL. Furthermore, you're using kill -9 pretty indiscriminately. See stackoverflow.com/questions/690415/… . If you want to kill defunct children, you might try: parents_of_dead_kids=$(ps -ef | grep [d]efunct | awk '{print $3}' | sort | uniq | egrep -v '^1$'); echo "$parents_of_dead_kids" | xargs kill. Rerun the script after 30 seconds or so, with the kill -9 if you desire. (Note that I specifically disallow killing of Init) – Mike S Sep 1 '16 at 14:50

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 by init(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.

Thank you Mike S. We took your line and wrote a script that will kill defunct processes whose parent is in.telnetd. We didn't want it to kill any parent process, just telnetd that we know is causing a problem and we'll run it multiple times to kill multiple ones if needed.

# egrep -v '^1$ = Make sure the process is not the init process.
# awk '{print $3}' = Print the parent process.

first_parent_of_first_dead_kid=$(ps -ef | grep [d]efunct | awk '{print $3}' | head -n1 | egrep -v '^1$')
echo "$first_parent_of_first_dead_kid"

# If the first parent of the first dead kid is in.telnetd, then kill it.
if ps -ef | grep $first_parent_of_first_dead_kid | grep in.telnetd;then
        echo "We have a defunct process whose parent process is in.telnetd" | logger -t KILL-DEFUNCT-TELNET
        echo "killing $first_parent_of_first_dead_kid" | logger -t KILL-DEFUNCT-TELNET
        kill $first_parent_of_first_dead_kid 2>&1 | logger -t KILL-DEFUNCT-TELNET
fi

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.