mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
Kernel/ProcFS: Clean dead processes properly
Now we use WeakPtrs to break Ref-counting cycle. Also, we call the prepare_for_deletion method to ensure deleted objects are ready for deletion. This is necessary to ensure we don't keep dead processes, which would become zombies. In addition to that, add some debug prints to aid debug in the future.
This commit is contained in:
parent
5073bf8e75
commit
3344f91fc4
6 changed files with 103 additions and 43 deletions
|
@ -459,8 +459,12 @@ void Thread::finalize_dying_threads()
|
|||
});
|
||||
}
|
||||
for (auto* thread : dying_threads) {
|
||||
RefPtr<Process> process = thread->process();
|
||||
dbgln_if(PROCESS_DEBUG, "Before finalization, {} has {} refs and its process has {}",
|
||||
*thread, thread->ref_count(), thread->process().ref_count());
|
||||
thread->finalize();
|
||||
|
||||
dbgln_if(PROCESS_DEBUG, "After finalization, {} has {} refs and its process has {}",
|
||||
*thread, thread->ref_count(), thread->process().ref_count());
|
||||
// This thread will never execute again, drop the running reference
|
||||
// NOTE: This may not necessarily drop the last reference if anything
|
||||
// else is still holding onto this thread!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue