Fix: custom signal handler not working
This commit is contained in:
@@ -27,11 +27,9 @@ void _sigkill_default_handler()
|
||||
|
||||
void run_signal(int32_t SIGNAL)
|
||||
{
|
||||
LOG("run_signal"); DEBUG_SIGNAL(SIGNAL);
|
||||
process_t *process = get_current()->process;
|
||||
process->current_signal = SIGNAL;
|
||||
trapframe_t *regs = kmalloc(sizeof(trapframe_t));
|
||||
memcpy(regs, process->regs, sizeof(trapframe_t));
|
||||
LOG("run_signal"); LOG(process->sighandlers[SIGNAL]); DEBUG_SIGNAL(SIGNAL);
|
||||
|
||||
if (!process->sighandlers[SIGNAL]) {
|
||||
switch (SIGNAL) {
|
||||
@@ -40,20 +38,39 @@ void run_signal(int32_t SIGNAL)
|
||||
break;
|
||||
default:
|
||||
LOG("No default handler for this signal"); DEBUG_SIGNAL(SIGNAL);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
*regs = (trapframe_t){
|
||||
DEBUG_SIGNAL(process->sighandlers[SIGNAL]);
|
||||
|
||||
process->retregs = process->regs;
|
||||
process->regs = kmalloc(sizeof(trapframe_t));
|
||||
memcpy(process->regs, process->retregs, sizeof(trapframe_t));
|
||||
*process->regs = (trapframe_t){
|
||||
.x0 = (uint64_t)process->sighandlers[SIGNAL],
|
||||
.elr_el1 = (uint64_t)_sighandler_wrapper,
|
||||
.sp_el0 = ((uint64_t)process->sigstack + process->sigstack_size - 64),
|
||||
};
|
||||
|
||||
disable_interrupt();
|
||||
process->current_signal = 0x0;
|
||||
process->current_signal = SIGNAL;
|
||||
process->sigstate[SIGNAL] = false;
|
||||
user_exec(regs);
|
||||
user_exec(process->regs);
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
void end_signal()
|
||||
{
|
||||
DEBUG_SIGNAL("end_signal");
|
||||
process_t *process = get_current()->process;
|
||||
|
||||
disable_interrupt();
|
||||
process->current_signal = 0x0;
|
||||
kfree(process->regs);
|
||||
process->regs = process->retregs;
|
||||
user_exec(process->regs);
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user