From 1d5e56659af7945daac0f79a06b839bfd59c8f1f Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 4 Oct 2021 21:01:31 +0200 Subject: remove support for processes returning strings on exit This isn't really all that useful, it doesn't enable anything that wasn't possible before. With it removed I'll be able to implement process_exit() in a much simpler way. --- src/kernel/proc.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/kernel/proc.h') diff --git a/src/kernel/proc.h b/src/kernel/proc.h index 82bb59a..592451c 100644 --- a/src/kernel/proc.h +++ b/src/kernel/proc.h @@ -26,10 +26,7 @@ struct process { // saved value, meaning depends on .state union { - struct { // PS_DEAD, PS_WAITS4CHILDDEATH - char __user *buf; - size_t len; - } death_msg; + int death_msg; // PS_DEAD struct vfs_request pending_req; // PS_WAITS4FS struct { char __user *buf; -- cgit v1.2.3 From 33ef18732abb1ec03469b7c0fe271a6599318682 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 4 Oct 2021 21:37:01 +0200 Subject: implement process_kill() --- src/kernel/proc.c | 6 ++++++ src/kernel/proc.h | 2 ++ src/kernel/syscalls.c | 4 +--- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/kernel/proc.h') diff --git a/src/kernel/proc.c b/src/kernel/proc.c index b1dc5c1..47fd2ec 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -103,6 +103,12 @@ handle_t process_find_handle(struct process *proc) { return handle; } +void process_kill(struct process *proc, int ret) { + proc->state = PS_DEAD; + proc->death_msg = ret; + process_try2collect(proc); +} + int process_try2collect(struct process *dead) { struct process *parent = dead->parent; int len, ret; diff --git a/src/kernel/proc.h b/src/kernel/proc.h index 592451c..7c338bb 100644 --- a/src/kernel/proc.h +++ b/src/kernel/proc.h @@ -53,6 +53,8 @@ _Noreturn void process_switch_any(void); // switches to any running process struct process *process_find(enum process_state); handle_t process_find_handle(struct process *proc); // finds the first free handle +void process_kill(struct process *proc, int ret); + /** Tries to transistion from PS_DEAD to PS_DEADER. * @return a nonnegative length of the quit message if successful, a negative val otherwise*/ int process_try2collect(struct process *dead); diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index c89efc7..22bf1f6 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -9,9 +9,7 @@ #include _Noreturn void _syscall_exit(int ret) { - process_current->state = PS_DEAD; - process_current->death_msg = ret; - process_try2collect(process_current); + process_kill(process_current, ret); process_switch_any(); } -- cgit v1.2.3