1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:18:13 +00:00

Kernel: Change wait blocking to Process-only blocking

This prevents zombies created by multi-threaded applications and brings
our model back to closer to what other OSs do.

This also means that SIGSTOP needs to halt all threads, and SIGCONT needs
to resume those threads.
This commit is contained in:
Tom 2020-12-08 21:18:45 -07:00 committed by Andreas Kling
parent 47ede74326
commit c455fc2030
11 changed files with 284 additions and 203 deletions

View file

@ -577,7 +577,7 @@ KResultOr<String> Process::get_syscall_path_argument(const Syscall::StringArgume
return get_syscall_path_argument(path.characters, path.length);
}
void Process::finalize(Thread& last_thread)
void Process::finalize()
{
ASSERT(Thread::current() == g_finalizer);
#ifdef PROCESS_DEBUG
@ -627,7 +627,7 @@ void Process::finalize(Thread& last_thread)
}
}
unblock_waiters(last_thread, Thread::WaitBlocker::UnblockFlags::Terminated);
unblock_waiters(Thread::WaitBlocker::UnblockFlags::Terminated);
{
ScopedSpinLock lock(m_lock);
@ -647,10 +647,10 @@ void Process::disowned_by_waiter(Process& process)
m_wait_block_condition.disowned_by_waiter(process);
}
void Process::unblock_waiters(Thread& thread, Thread::WaitBlocker::UnblockFlags flags, u8 signal)
void Process::unblock_waiters(Thread::WaitBlocker::UnblockFlags flags, u8 signal)
{
if (auto parent = Process::from_pid(ppid()))
parent->m_wait_block_condition.unblock(thread, flags, signal);
parent->m_wait_block_condition.unblock(*this, flags, signal);
}
void Process::die()
@ -877,4 +877,21 @@ OwnPtr<Process::ELFBundle> Process::elf_bundle() const
return bundle;
}
void Process::start_tracing_from(ProcessID tracer)
{
m_tracer = ThreadTracer::create(tracer);
}
void Process::stop_tracing()
{
m_tracer = nullptr;
}
void Process::tracer_trap(Thread& thread, const RegisterState& regs)
{
ASSERT(m_tracer.ptr());
m_tracer->set_regs(regs);
thread.send_urgent_signal_to_self(SIGTRAP);
}
}