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:

  1. It calls __exit_signal(), which calls __unhash_process(), which in turns calls detach_pid() to remove the process from the pidhash and remove the process from the task list.
  2. __exit_signal() releases any remaining resources used by the now dead process and finalizes statistics and bookkeeping.
  3. 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.
  4. release_task() calls put_task_struct() to free the pages containing the process’s kernel stack and thread_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()

results matching ""

    No results matching ""