Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (6.1k points)

What I know is that a Zombie is created when a parent process does not use the wait system call after a child dies to read its exit status, and whenever a process that is reclaimed by init is called as an orphan process when the original parent process terminates before the child.

How does memory management is done on UNIX and basically how these are handled?

1 Answer

0 votes
by (11.7k points)

In Linux, the moment a child exits, any process has to wait on it to get its exit code. Now the process table keeps its code, as long as it happens. Now, this code is read and is termed as reaping the child.

So in the time a child exits and is reaped, it is referred to as a zombie. Zombies just preserve and occupy their space in the process table. 

No memory or CPU is taken by them. Whereas the process table is a finite resource, and excessive zombies can fill its place so that no other processes can launch. And they should be strongly avoided.

If a process exits and its children are still running, those children are orphans. init  adopts orphan children. An orphan is just a process. It will use whatever resources it uses. Children are automatically reaped by init. Therefore if you don’t clean up your children while exiting, they will not turn out zombies.

But zombies from the longest times on the systems do exist. They are nothing but the former children of an existing process that hasn't reaped them. The process may go to a hung state. Or it might be written improperly and forgets to reap its children. Or it's overloaded and hasn't gotten around to it. But for some reason, the parent process continues to exist so they aren't orphans, and they haven't been waited on, therefore in the process table, they live like zombies. 

Therefore if you get to know about a zombie for a little longer, it means the parent process has some problem and your program needs amendments. 

Related questions

0 votes
1 answer
asked Feb 15, 2021 in Linux by rahulnayar01123 (6.1k points)
0 votes
1 answer

Browse Categories

...