diff options
author | dzwdz | 2021-10-04 21:37:01 +0200 |
---|---|---|
committer | dzwdz | 2021-10-04 21:37:01 +0200 |
commit | 33ef18732abb1ec03469b7c0fe271a6599318682 (patch) | |
tree | 7e3c98ab62aff568d793632e206011def778711e /src/kernel | |
parent | 1d5e56659af7945daac0f79a06b839bfd59c8f1f (diff) |
implement process_kill()
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/proc.c | 6 | ||||
-rw-r--r-- | src/kernel/proc.h | 2 | ||||
-rw-r--r-- | src/kernel/syscalls.c | 4 |
3 files changed, 9 insertions, 3 deletions
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 <stdint.h> _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(); } |