I learned in a textbook that Linux keeps the process descriptors when the process becomes a zombie until future parent verifies the exit status. I understand that process descriptor comes in two structs: task_struct
in slab, and thread_info
in kernel stack (forget x86).
I am reading through <kernel/exit.c> do_exit()
part of the source code, but I don't quite get where kernel stack is deallocated. I can find that exit_notify()
changes the process' status to zombie. and the rest of the code looks like its about cleaning up mostly locks and stuff until schedule()
.
I can't seem to find the part for deallocating kernel stack? or am I not understanding how kernel stacks work?
Or perhaps thread_info
is not considered to be kept at all and was already discarded along with kernel stack before changing into zombie?
What is exactly going on?
After a bit of digging, I think I have finally found it...
void free_task(struct task_struct *tsk)
{
prop_local_destroy_single(&tsk->dirties);
account_kernel_stack(tsk->stack, -1);
free_thread_info(tsk->stack);
rt_mutex_debug_task_free(tsk);
ftrace_graph_exit_task(tsk);
free_task_struct(tsk);
}
on parent verifying the zombie,
put_task_struct()->__put_task_struct()->free_task()
does free the kernel stack.
So, the answer is Yes. Zombie processes do keep the kernel stack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With