Kernel: fork() now clones current thread

This is how posix specifies thread cloning during fork
This commit is contained in:
Bananymous 2023-06-04 17:39:23 +03:00
parent e97585daf9
commit 94d2090777
1 changed files with 2 additions and 4 deletions

View File

@ -168,9 +168,6 @@ namespace Kernel
for (auto* mapped_range : m_mapped_ranges)
MUST(forked->m_mapped_ranges.push_back(mapped_range->clone(forked->page_table())));
ASSERT(m_threads.size() == 1);
ASSERT(m_threads.front() == &Thread::current());
for (auto& allocator : m_fixed_width_allocators)
if (allocator->allocations() > 0)
MUST(forked->m_fixed_width_allocators.push_back(MUST(allocator->clone(forked->page_table()))));
@ -178,7 +175,8 @@ namespace Kernel
if (m_general_allocator)
forked->m_general_allocator = MUST(m_general_allocator->clone(forked->page_table()));
Thread* thread = MUST(m_threads.front()->clone(forked, rsp, rip));
ASSERT(this == &Process::current());
Thread* thread = MUST(Thread::current().clone(forked, rsp, rip));
forked->add_thread(thread);
register_process(forked);