aboutsummaryrefslogtreecommitdiff
path: root/src/uapi
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-11-02 16:02:41 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2024-11-02 16:02:41 +0200
commit21efbba39340300a7ba9d5f4f94017f5ff956833 (patch)
treec9116d4e38a574a8edae7cdcebcd7569af9cb5a7 /src/uapi
parentd127146846f4d6561e15000d1469b715dafdb627 (diff)
downloadkmi-21efbba39340300a7ba9d5f4f94017f5ff956833.tar.gz
kmi-21efbba39340300a7ba9d5f4f94017f5ff956833.zip
intial working sys_spawn
Diffstat (limited to 'src/uapi')
-rw-r--r--src/uapi/proc.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/uapi/proc.c b/src/uapi/proc.c
index 8d90687..51a1252 100644
--- a/src/uapi/proc.c
+++ b/src/uapi/proc.c
@@ -128,7 +128,11 @@ SYSCALL_DEFINE2(exec)(struct tcb *t, sys_arg_t bin, sys_arg_t interp)
if (prepare_proc(t, bin, interp))
return_args1(t, ERR_INVAL);
+ set_thread(t);
+ set_return(t, t->callback);
set_ret4(t, 0, t->tid, SYS_USER_SPAWNED, t->pid);
+
+ flush_tlb_full();
}
/**
@@ -150,16 +154,24 @@ SYSCALL_DEFINE2(spawn)(struct tcb *t, sys_arg_t bin, sys_arg_t interp)
if (!n)
return_args1(t, ERR_OOMEM);
- /** @todo copy over bin and interp into new process, this is not enough */
n->notify_id = c->notify_id;
- stat_t ret = OK;
- if ((ret = prepare_proc(n, bin, interp))) {
+ if (prepare_proc(n, bin, interp)) {
/* this kills the thread */
orphanize(t);
unorphanize(t);
- return_args1(t, ret);
+ return_args1(t, ERR_INVAL);
}
+ /** @todo should permissions be transferred? Probably, not but now there
+ * is a slightly annoying asymmetry between fork+exec vs spawn... */
+
+ /* temporarily switch to new thread to manipulate stack */
+ use_tcb(n);
+ set_thread(n);
+ set_return(n, n->callback);
+ set_ret4(n, 0, n->tid, SYS_USER_SPAWNED, n->pid);
+ use_tcb(t);
+
return_args1(t, n->pid);
}