Do zombie processes cause memory shortage? Do they get killed by the init process eventually?
Matthew Harrington
I have a zombie process problem.
I read What is a <defunct> process, and why doesn't it get killed? which says
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.
I don't understand this.
Does it mean that eventually the zombie process's entry will be deleted from process table and killed successfully by the init process (Pid = 1)?
I think zombie processes causes a memory shortage problem, because they don't return allocated memory space.
Am I right?
2 Answers
Zombie processes don’t use up any system resources. (Actually, each one uses a very tiny amount of system memory to store its process descriptor.) However, each zombie process retains its process ID (PID)
Linux systems have a finite number of process IDs – 32767 by default on 32-bit systems. If zombies are accumulating at a very quick rate – for example, if improperly programmed server software is creating zombie processes under load — the entire pool of available PIDs will eventually become assigned to zombie processes, preventing other processes from launching.
Getting Rid of Zombie Processes
kill -s SIGCHLD pid
Credit goes to : HTG
2No, Actually zombie process is
In UNIX System terminology, a process that has terminated, but whose parent has not yet waited for it, is called a zombie. The ps(1) command prints the state of a zombie process as Z. If we write a long-running program that forks many child processes, they become zombies unless we wait for them and fetch their termination status.
The final condition to consider is this: What happens when a process that has been inherited by init terminates? Does it become a zombie? The answer is ‘‘no,’’ because init is written so that whenever one of its children terminates, init calls one of the wait functions to fetch the termination status. By doing this, init prevents the system from being clogged by zombies. When we say ‘‘one of init’s children,’’ we mean either a process that init generates directly (such as getty, which we describe in Section 9.2) or a process whose parent has terminated and has been subsequently inherited by init. from Advance unix Programming by stevence rechard