Removing Process Descriptor
After do_exit()
completes, the process descriptor for the terminated process still exists, but the process is a zombie and is unable to run. This enables the system to obtain information about a child process after it has terminated.
Cleaning up after a process and removing its process descriptor are separate.
The wait()
functions is to suspend execution of the calling task until one of its children exits, at which time the function returns with the PID of the exited child.
When it is time to finally deallocate the process descriptor, release_task()
is invoked. It does the following:
- It calls
__exit_signal()
, which calls__unhash_process()
, which in turns callsdetach_pid()
to remove the process from the pidhash and remove the process from the task list. __exit_signal()
releases any remaining resources used by the now dead process and finalizes statistics and bookkeeping.- If the task was the last member of a thread group, and the leader is a zombie, then
release_task()
notifies the zombie leader’s parent. release_task()
callsput_task_struct()
to free the pages containing the process’s kernel stack andthread_info
structure and deallocate the slab cache containing the task_struct.
At this point, the process descriptor and all resources belonging solely to the process have been freed.
tldr: do_exit()
-> wait()
-> release_task()