diff options
author | Liav A <liavalb@gmail.com> | 2021-07-01 19:18:38 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-02 13:16:12 +0200 |
commit | 3344f91fc499ef7d91078f5b2498649fc9468a41 (patch) | |
tree | 5ade2964f3cb8f17895d05693a9b7c0187cd65ec /Kernel/Thread.cpp | |
parent | 5073bf8e75a1e71be8bbcdc96c10c3711e8ae22c (diff) | |
download | serenity-3344f91fc499ef7d91078f5b2498649fc9468a41.zip |
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.
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r-- | Kernel/Thread.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 7794a2afdd..e11244ea8d 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -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! |