3

I am reading a textbook on parent/child process, and the author says:

If a parent process terminates without reaping its zombie children, then the kernel arranges for the init process to reap them. However, long-running programs such as shells or servers should always reap their zombie children. Even though zombies are not running, they still consume system memory resources.

but according to the answer of this question What does reaping children imply?
it seems that most/all of zombies' resources are released, only one resource that's definitely still consumed is that process table slot. I am not familiar with the process table slot, but I think it stores exit status of zombies.

Anyway, so one record in the process table slot doesn't sound like a big deal, probably just consumes a couple of bytes/kb in memory, so why long-running programs should always reap their zombie children by calling wait variants?

5
  • 2
    The problem is not one or two zombie processes, but an ever growing number of them. If for example the long-running process is a shell which can call any other program. These progams called may not reap it's children, so the shell inherits them. If now the shell calls many of such programs (which it might since the user controls what the shell does) the number of zomies might get really big if the shell does not regularly reap it's inherited childrens.
    – Ackdari
    Sep 8, 2020 at 11:39
  • Long-running can mean years. Let's randomly guess that a zombie uses 200 bytes. If you manage to leak one per minute for a year, you have burned 100 megabytes of unswappable kernel memory on useless zombies. And things like ps and top now have to wade through half a million processes in Z state.
    – user14215102
    Sep 8, 2020 at 11:42
  • 3
    And of course on 32-bit linux the PID limit was 32768, zombies do not release their PID, once you run out of PIDs, the system is hosed.
    – user14215102
    Sep 8, 2020 at 11:48
  • 1
    @Ackdari Orphans are always inherited by init, not by their grandparent.
    – user253751
    Sep 8, 2020 at 11:49
  • I think the irritation is a bigger problem than the modest leak of resources. Trying to find a particular running process, when you've got hundreds of zombies with the same name, gets old real fast. Sep 8, 2020 at 12:09

1 Answer 1

3

There is a maximum number of processes, and it can be as low as 32768.

Zombie processes still count as processes for this purpose.

If you create many thousands of zombie processes and don't reap them, the system won't be able to create any more processes. And that's bad.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.