diff --git a/core/panic/user.cpp b/core/panic/user.cpp index 5f9251b..891a70e 100644 --- a/core/panic/user.cpp +++ b/core/panic/user.cpp @@ -153,6 +153,7 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame) dbgPrint(Frame); #endif + int sigRet = -1; switch (Frame->InterruptNumber) { case CPU::x86::PageFault: @@ -169,15 +170,15 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame) return true; } - proc->Signals.SendSignal(SIGSEGV, - {Tasking::KILL_CRASH}); + sigRet = proc->Signals.SendSignal(SIGSEGV, + {Tasking::KILL_CRASH}); break; } case CPU::x86::Debug: case CPU::x86::Breakpoint: { - proc->Signals.SendSignal(SIGTRAP, - {Tasking::KILL_CRASH}); + sigRet = proc->Signals.SendSignal(SIGTRAP, + {Tasking::KILL_CRASH}); break; } case CPU::x86::DivideByZero: @@ -186,21 +187,21 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame) case CPU::x86::x87FloatingPoint: case CPU::x86::SIMDFloatingPoint: { - proc->Signals.SendSignal(SIGFPE, - {Tasking::KILL_CRASH}); + sigRet = proc->Signals.SendSignal(SIGFPE, + {Tasking::KILL_CRASH}); break; } case CPU::x86::InvalidOpcode: case CPU::x86::GeneralProtectionFault: { - proc->Signals.SendSignal(SIGILL, - {Tasking::KILL_CRASH}); + sigRet = proc->Signals.SendSignal(SIGILL, + {Tasking::KILL_CRASH}); break; } case CPU::x86::DeviceNotAvailable: { - proc->Signals.SendSignal(SIGBUS, - {Tasking::KILL_CRASH}); + sigRet = proc->Signals.SendSignal(SIGBUS, + {Tasking::KILL_CRASH}); break; } case CPU::x86::NonMaskableInterrupt: @@ -221,6 +222,13 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame) } } + if (sigRet == 0) + { + trace("User mode exception handler handled"); + thread->SetState(Tasking::Ready); + return true; + } + error("User mode exception handler failed"); return false; } diff --git a/tasking/signal.cpp b/tasking/signal.cpp index 71575ed..ae77a02 100644 --- a/tasking/signal.cpp +++ b/tasking/signal.cpp @@ -611,7 +611,7 @@ namespace Tasking pcb->SetState(Zombie); else pcb->SetState(Terminated); - return 0; + return val.sival_int == Tasking::KILL_CRASH ? -EFAULT : 0; } case SIG_IGN: { @@ -635,7 +635,7 @@ namespace Tasking pcb->SetState(CoreDump); else pcb->SetState(Terminated); - return 0; + return val.sival_int == Tasking::KILL_CRASH ? -EFAULT : 0; } case SIG_STOP: {