Welcome to the Linux Foundation Forum!

LFS201 - Chapter 12 Discussion // Questions // Banter

Options

Chapter 12
Process Monitoring

Comments

  • heiko_s
    heiko_s Posts: 99
    edited June 2020
    Options

    Referring to chapter 12, viewing process states with ps, I got the following question:

    If and how to deal with zombies?

    Here is an example:
    heiko@LM20-heiko:~$ ps -elf | grep defunct
    0 Z heiko 1679 1527 0 80 0 - 0 - 17:30 ? 00:00:01 [get_apt_cache.p]
    0 S heiko 5755 5687 0 80 0 - 2258 pipe_w 20:19 pts/0 00:00:00 grep --color=auto defunct

    I was searching for defunct processes and found the zombie above. My (mis)understanding(?) is that zombies are fine. Please correct me if I'm wrong. Is there a way to clean up these defunct processes?

    See also Viewing Process States with ps.

  • coop
    coop Posts: 915
    Options

    yes, zombie=defunct. In general, Linux does not suffer from the accumulation of zombies. A zombie is simply a process who has finished its work but no one has collected its exit code; all memory and other resources are released. If the parent process is still alive the zombie process will stick around until the parent collects its exit code and then it will disappear. If the parent dies (usually before the child anyway), the process is "adopted" by the init process (PID=1 usually) and when the child dies, the init process "reaps" it and the zombie is gone. On systems I worked on years ago, like Solaris this kind of "child reaping" did not go on and you could accumulate a boatload of zombies which could only be killed with a reboot.

    If you want to kill a defunct process really the only way to do it is to kill the parent that forked it to begin with. For example, if you have a mount operation on an NFS share that failed for some reason and went defunct, if you kill nfs completely it might reap the zombie -- I've seen this fail as well as succeed.

  • heiko_s
    heiko_s Posts: 99
    Options

    Thanks coop. Yeah, not too many zombies around these days. Only this one [get_apt_cache.p] process goes defunct. Might be normal, don't know. System works, though it's just a kinda cut&paste passthrough VM I created for these exercises.

Categories

Upcoming Training