mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +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:
parent
47ede74326
commit
c455fc2030
11 changed files with 284 additions and 203 deletions
|
@ -94,10 +94,10 @@ int handle(RegisterState& regs, u32 function, u32 arg1, u32 arg2, u32 arg3)
|
|||
if (function == SC_exit || function == SC_exit_thread) {
|
||||
// These syscalls need special handling since they never return to the caller.
|
||||
|
||||
if (auto* tracer = current_thread->tracer(); tracer && tracer->is_tracing_syscalls()) {
|
||||
if (auto* tracer = process.tracer(); tracer && tracer->is_tracing_syscalls()) {
|
||||
regs.eax = 0;
|
||||
tracer->set_trace_syscalls(false);
|
||||
current_thread->tracer_trap(regs); // this triggers SIGTRAP and stops the thread!
|
||||
process.tracer_trap(*current_thread, regs); // this triggers SIGTRAP and stops the thread!
|
||||
}
|
||||
|
||||
cli();
|
||||
|
@ -137,10 +137,11 @@ void syscall_handler(TrapFrame* trap)
|
|||
{
|
||||
auto& regs = *trap->regs;
|
||||
auto current_thread = Thread::current();
|
||||
auto& process = current_thread->process();
|
||||
|
||||
if (auto* tracer = current_thread->tracer(); tracer && tracer->is_tracing_syscalls()) {
|
||||
if (auto tracer = process.tracer(); tracer && tracer->is_tracing_syscalls()) {
|
||||
tracer->set_trace_syscalls(false);
|
||||
current_thread->tracer_trap(regs); // this triggers SIGTRAP and stops the thread!
|
||||
process.tracer_trap(*current_thread, regs); // this triggers SIGTRAP and stops the thread!
|
||||
}
|
||||
|
||||
current_thread->yield_if_stopped();
|
||||
|
@ -160,7 +161,6 @@ void syscall_handler(TrapFrame* trap)
|
|||
asm volatile(""
|
||||
: "=m"(*ptr));
|
||||
|
||||
auto& process = current_thread->process();
|
||||
if (!MM.validate_user_stack(process, VirtualAddress(regs.userspace_esp))) {
|
||||
dbgln("Invalid stack pointer: {:p}", regs.userspace_esp);
|
||||
handle_crash(regs, "Bad stack on syscall entry", SIGSTKFLT);
|
||||
|
@ -189,9 +189,9 @@ void syscall_handler(TrapFrame* trap)
|
|||
|
||||
process.big_lock().unlock();
|
||||
|
||||
if (auto* tracer = current_thread->tracer(); tracer && tracer->is_tracing_syscalls()) {
|
||||
if (auto tracer = process.tracer(); tracer && tracer->is_tracing_syscalls()) {
|
||||
tracer->set_trace_syscalls(false);
|
||||
current_thread->tracer_trap(regs); // this triggers SIGTRAP and stops the thread!
|
||||
process.tracer_trap(*current_thread, regs); // this triggers SIGTRAP and stops the thread!
|
||||
}
|
||||
|
||||
current_thread->yield_if_stopped();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue