mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 07:07:23 +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:
@@ -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!
|
||||
|
||||
Reference in New Issue
Block a user