diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-08 17:38:59 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-08 17:38:59 +0300 |
| commit | 7e828ec1e1479ff9a8afe845539d08ca0dfada5f (patch) | |
| tree | a227c58b30c99058fc10ff3caffeebca7dbd5913 /src/uapi/proc.c | |
| parent | 219c27d420fe0abe5515cefc2513c6fe60aafdf9 (diff) | |
| download | kmi-7e828ec1e1479ff9a8afe845539d08ca0dfada5f.tar.gz kmi-7e828ec1e1479ff9a8afe845539d08ca0dfada5f.zip | |
add orphan checking to timer and irq handling
Diffstat (limited to 'src/uapi/proc.c')
| -rw-r--r-- | src/uapi/proc.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/uapi/proc.c b/src/uapi/proc.c index 293a01f..eddbab8 100644 --- a/src/uapi/proc.c +++ b/src/uapi/proc.c @@ -11,6 +11,7 @@ #include <kmi/proc.h> #include <kmi/bits.h> #include <kmi/power.h> +#include <kmi/assert.h> #include <kmi/notify.h> #include <kmi/orphanage.h> #include <kmi/regions.h> @@ -127,7 +128,18 @@ SYSCALL_DEFINE2(exec)(struct tcb *t, sys_arg_t bin, sys_arg_t interp) if (interp) clear_bit(b->flags, MR_KEEP); - return_args1(t, prepare_proc(t, bin, interp)); + /* should hopefully never actually fail, but if it does, we don't really + * have any choice but to kill the thread. */ + if (prepare_proc(t, bin, interp)) { + /* this kills the thread */ + orphanize(t); + unorphanize(t); + /* should never be reached as we control the thread so we should + * be able to directly jump to pid 1 */ + assert(false); + } + + return_args4(t, 0, t->tid, SYS_USER_SPAWNED, t->pid); } /** |
