kernel: clear signal disposition when running a handler, as we should

This commit is contained in:
K. Lange 2022-03-04 22:03:21 +09:00
parent e07291a0b1
commit 6ff1bc5195
2 changed files with 4 additions and 3 deletions

View File

@ -13,7 +13,6 @@
typedef struct {
int signum;
uintptr_t handler;
} signal_t;
extern void fix_signal_stacks(void);

View File

@ -87,10 +87,11 @@ static void maybe_restart_system_call(struct regs * r) {
}
int handle_signal(process_t * proc, signal_t * sig, struct regs *r) {
uintptr_t handler = sig->handler;
uintptr_t signum = sig->signum;
free(sig);
uintptr_t handler = proc->signals[signum];
/* Are we being traced? */
if (this_core->current_process->flags & PROC_FLAG_TRACE_SIGNALS) {
signum = ptrace_signal(signum, 0);
@ -134,6 +135,8 @@ int handle_signal(process_t * proc, signal_t * sig, struct regs *r) {
/* If the handler value is 1 we treat it as IGN. */
if (handler == 1) goto _ignore_signal;
proc->signals[signum] = 0;
arch_enter_signal_handler(handler, signum, r);
return 1; /* Should not be reachable */
@ -193,7 +196,6 @@ int send_signal(pid_t process, int signal, int force_root) {
/* Append signal to list */
signal_t * sig = malloc(sizeof(signal_t));
sig->handler = (uintptr_t)receiver->signals[signal];
sig->signum = signal;
spin_lock(sig_lock);