diff options
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/proc.c | 10 | ||||
-rw-r--r-- | src/kernel/proc.h | 5 | ||||
-rw-r--r-- | src/kernel/syscalls.c | 22 |
3 files changed, 12 insertions, 25 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c index b9f96c8..b1dc5c1 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -115,16 +115,12 @@ int process_try2collect(struct process *dead) { dead->state = PS_DEADER; parent->state = PS_RUNNING; - len = min(parent->death_msg.len, dead->death_msg.len); - res = virt_cpy( - parent->pages, parent->death_msg.buf, - dead->pages, dead->death_msg.buf, len); - - ret = res ? len : 0; + ret = dead->death_msg; regs_savereturn(&parent->regs, ret); return ret; default: - return -1; + return -1; // this return value isn't used anywhere + // TODO enforce that, somehow? idk } } 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; diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 1b91eb7..c89efc7 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -8,28 +8,22 @@ #include <shared/syscalls.h> #include <stdint.h> -_Noreturn void _syscall_exit(const char __user *msg, size_t len) { +_Noreturn void _syscall_exit(int ret) { process_current->state = PS_DEAD; - process_current->death_msg.buf = (userptr_t) msg; // discarding const - process_current->death_msg.len = len; + process_current->death_msg = ret; process_try2collect(process_current); process_switch_any(); } -int _syscall_await(char __user *buf, int len) { +int _syscall_await(void) { bool has_children = false; process_current->state = PS_WAITS4CHILDDEATH; - process_current->death_msg.buf = buf; - process_current->death_msg.len = len; // find any already dead children for (struct process *iter = process_current->child; iter; iter = iter->sibling) { - if (iter->state == PS_DEAD) { - int ret = process_try2collect(iter); - assert(ret >= 0); - return ret; - } + if (iter->state == PS_DEAD) + return process_try2collect(iter); if (iter->state != PS_DEADER) has_children = true; } @@ -38,7 +32,7 @@ int _syscall_await(char __user *buf, int len) { process_switch_any(); // wait until a child dies else { process_current->state = PS_RUNNING; - return -1; // error + return ~0; // TODO errno } } @@ -276,9 +270,9 @@ int _syscall_memflag(void __user *addr, size_t len, int flags) { int _syscall(int num, int a, int b, int c, int d) { switch (num) { case _SYSCALL_EXIT: - _syscall_exit((userptr_t)a, b); + _syscall_exit(a); case _SYSCALL_AWAIT: - return _syscall_await((userptr_t)a, b); + return _syscall_await(); case _SYSCALL_FORK: return _syscall_fork(); case _SYSCALL_OPEN: |