Can somebody please explain when parent process receives the exit status of a dead child process via wait
, who actually reallocates the memory of the child process and removes it from the process table?
Removing zombie process from the process table
Architectureexitprocessprocess-managementzombie-process
Best Answer
Manipulating the process table and the memory mappings is always the kernel's job. The kernel acts when some process makes a system call. When a process exits, all of the resources that it uses, including memory, except for the entry in the process table, are deleted − that's what the
_exit
system call does. Then, when the parent process callswait
orwaitpid
, part of that system call's job is to clean up the process table entry. The parent process may decide to callwait
whenever it wants (if the parent isinit
, it callswait
pretty much all the time).