1

I am reading book The Linux Programming Interface, I see the following 2 paragraphs about zombie process sort of conflicting:

When the parent does perform a wait(), the kernel removes the zombie, since the last remaining information about the child is no longer required. On the other hand, if the parent terminates without doing a wait(), then the init process adopts the child and automatically performs a wait(), thus removing the zombie process from the system.

If a parent creates a child, but fails to perform a wait(), then an entry for the zombie child will be maintained indefinitely in the kernel’s process table. If a large number of such zombie children are created, they will eventually fill the kernel process table, preventing the creation of new processes.

The first paragraph says, even the parent process did not call wait() and terminated the long running child process, init would pick the zombie process and clear the child process off upon its termination.

The following paragraph says, if the parent process does not call wait(), then its long running child processes will become zombie and occupy kernel process table forever.

I am confused - how can the situation of 2nd paragraph happens if init takes care of picking up zombie process? Or in what situation will init miss picking up zombie?

[Update] Yes, I misread the text, thanks Barmar, these 2 paragraphs talk about different scenarios.

my_question
  • 3,075
  • 2
  • 27
  • 44
  • 1
    They're not talking about the same thing. The first is about children that remain after the parent exits. The second is about the children that are not waited for and the parent does NOT exit. – Barmar Dec 26 '22 at 20:09

1 Answers1

0

Actually if the init was not there then the situation of second paragraph would happen. The init runs periodically that takes care of the zombie process. More can be found here

ibex404
  • 33
  • 2
  • 9