diff options
author | Ian Moffett <ian@osmora.org> | 2025-05-28 22:37:52 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-05-28 22:37:52 -0400 |
commit | ca77ee47c467f723ba9b1d6ca0bae5966c642492 (patch) | |
tree | 910d1d4523d946dab4e794409799ea2d3874cf2d | |
parent | 415fb9894a4cbd761791ef1e218a5b01089cf80d (diff) |
kernel: exit: Ensure curtd is NULL if killed
If the current process is killed, make sure that we set the pointer
to the currently running process to NULL.
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/kern/kern_exit.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index da1e3cf..39fa96d 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -35,6 +35,7 @@ #include <vm/vm.h> #include <vm/map.h> #include <machine/pcb.h> +#include <machine/cpu.h> #define pr_trace(fmt, ...) kprintf("exit: " fmt, ##__VA_ARGS__) #define pr_error(...) pr_trace(__VA_ARGS__) @@ -87,9 +88,11 @@ exit1(struct proc *td, int flags) { struct pcb *pcbp; struct proc *curtd, *procp; + struct cpu_info *ci; uintptr_t stack; pid_t target_pid, curpid; + ci = this_cpu(); target_pid = td->pid; curtd = this_td(); pcbp = &td->pcb; @@ -134,8 +137,10 @@ exit1(struct proc *td, int flags) * If we are the thread exiting, reenter the scheduler * and do not return. */ - if (target_pid == curpid) + if (target_pid == curpid) { + ci->curtd = NULL; sched_enter(); + } return 0; } |