summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2023-04-06 05:57:57 +0300
committerJelle Raaijmakers <jelle@gmta.nl>2023-04-09 18:49:01 +0200
commit5a94e8dfd0f8dbd0cff64c209aa6be5e8dc03c5d (patch)
tree47eb00e8d5ae2d4175dc3f411692d02a8d16cf04 /Kernel/Process.cpp
parent67aceb6c67cb06b1b8607fa74a4fb6180a151fd1 (diff)
downloadserenity-5a94e8dfd0f8dbd0cff64c209aa6be5e8dc03c5d.zip
Kernel: Ensure jailed processes can be reaped by a jailed parent process
We were detaching from the jail process list too early. To ensure we detach properly, leverage the remove_from_secondary_lists method so the possibly jailed parent process can still see the dying process and therefore clean it properly.
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r--Kernel/Process.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 7fee2b8cd8..ea7fbacc98 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -785,13 +785,6 @@ void Process::finalize()
m_fds.with_exclusive([](auto& fds) { fds.clear(); });
with_mutable_protected_data([&](auto& protected_data) { protected_data.tty = nullptr; });
m_executable.with([](auto& executable) { executable = nullptr; });
- m_jail_process_list.with([this](auto& list_ptr) {
- if (list_ptr) {
- list_ptr->attached_processes().with([&](auto& list) {
- list.remove(*this);
- });
- }
- });
m_attached_jail.with([](auto& jail) {
if (jail)
jail->detach({});
@@ -845,6 +838,17 @@ void Process::unblock_waiters(Thread::WaitBlocker::UnblockFlags flags, u8 signal
waiter_process->m_wait_blocker_set.unblock(*this, flags, signal);
}
+void Process::remove_from_secondary_lists()
+{
+ m_jail_process_list.with([this](auto& list_ptr) {
+ if (list_ptr) {
+ list_ptr->attached_processes().with([&](auto& list) {
+ list.remove(*this);
+ });
+ }
+ });
+}
+
void Process::die()
{
auto expected = State::Running;