From d2f3644430aca045cebec25afd8208ef56aca5fc Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Thu, 18 Aug 2022 19:42:17 +0900 Subject: [PATCH] kernel: fixup ptrace signal delivery, again --- kernel/sys/process.c | 2 +- kernel/sys/ptrace.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sys/process.c b/kernel/sys/process.c index b27d9adf..4f419d5e 100644 --- a/kernel/sys/process.c +++ b/kernel/sys/process.c @@ -1030,7 +1030,7 @@ int waitpid(int pid, int * status, int options) { if (status) { *status = candidate->status; } - candidate->status = 0; + candidate->status &= ~0xFF; int pid = candidate->id; if (is_parent && (candidate->flags & PROC_FLAG_FINISHED)) { while (*((volatile int *)&candidate->flags) & PROC_FLAG_RUNNING); diff --git a/kernel/sys/ptrace.c b/kernel/sys/ptrace.c index 1e2f2625..7153e1b9 100644 --- a/kernel/sys/ptrace.c +++ b/kernel/sys/ptrace.c @@ -164,7 +164,7 @@ long ptrace_signal(int signal, int reason) { switch_task(0); int signum = (this_core->current_process->status >> 8); - this_core->current_process->status = 0x7F; + this_core->current_process->status = 0; return signum; } @@ -184,7 +184,7 @@ static void signal_and_continue(pid_t pid, process_t * tracee, int sig) { __sync_and_and_fetch(&tracee->flags, ~(PROC_FLAG_SUSPENDED)); /* Does the process have a pending signal? */ - if ((tracee->status >> 8) & 0xFF && !(tracee->status >> 16)) { + if ((tracee->status >> 8) & 0xFF && (!(tracee->status >> 16) || ((tracee->status >> 16) == 0xFF))) { tracee->status = (sig << 8); make_process_ready(tracee); } else if (sig) {