summaryrefslogtreecommitdiff
path: root/src/kernel/proc.c
diff options
context:
space:
mode:
authordzwdz2022-07-18 23:55:58 +0200
committerdzwdz2022-07-18 23:55:58 +0200
commit96f41ff64d8113307f1b60d2eb6852423db34d14 (patch)
tree5a85a9706a2a11d047f7f5c91f4964bd2167b1ee /src/kernel/proc.c
parent121794214fd5ae36609c30418dfaf1a073b8784c (diff)
syscalls: implement execbuf
i have been planning to implement something like this for a while now. it should be faster when doing consecutive syscalls (to be tested). it will also be helpful in writing the elf loader
Diffstat (limited to 'src/kernel/proc.c')
-rw-r--r--src/kernel/proc.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c
index 324f0b4..9f6f6b7 100644
--- a/src/kernel/proc.c
+++ b/src/kernel/proc.c
@@ -1,4 +1,5 @@
#include <kernel/arch/generic.h>
+#include <kernel/execbuf.h>
#include <kernel/main.h>
#include <kernel/mem/alloc.h>
#include <kernel/mem/virt.h>
@@ -135,6 +136,11 @@ void process_kill(struct process *p, int ret) {
process_transition(p, PS_DEAD);
p->death_msg = ret;
+ if (p->execbuf.buf) {
+ kfree(p->execbuf.buf);
+ p->execbuf.buf = NULL;
+ }
+
if (p->parent)
pagedir_free(p->pages); // TODO put init's pages in the allocator
@@ -199,7 +205,10 @@ static _Noreturn void process_switch(struct process *proc) {
assert(proc->state == PS_RUNNING);
process_current = proc;
pagedir_switch(proc->pages);
- sysexit(proc->regs);
+ if (proc->execbuf.buf)
+ execbuf_run(proc);
+ else
+ sysexit(proc->regs);
}
_Noreturn void process_switch_any(void) {