Understanding Zombie Process
Zombie Process is a state of process which has completed execution but still has an entry in the process table. These process have irresponsible parent process. The responsible Process table is a data structure in Linux kernel, that stores information about all current process.
The process table contain the PID, User, Scheduling value, Virtual memory, State, CPU, Memory etc.
Location of process is /proc and you can use ps, top, htop, pstree and many other tools to see the process or you can get the process table with a kernel module.
Example
An easy way to create a zombie process is to run fork and exit the child immediately and the parent will sleep and will not be informed about the exit. When a process exit(), all of the memory and resources associated with it are deallocated. Further note that if the parent process dies before the child, the kernel will reparent the child process to init.
The parent process use wait() to get info about the child state.
To get information if the process exit() correctly
To fix and remove zombie process entry from process table we need to inform parent process that child called exit.
We need to make the parent to wait() the status of child so it can report the exit of the child.
First we need to find the process parent id and zombie id, then we need to use gdb to attach on parent and call waitpid within the zombie id.
Example
sources
https://linux.die.net/man/2/waitpid:
https://en.wikipedia.org/wiki/Zombie_process