From efe937998ad14422469749b35331bb369a1c7c6a Mon Sep 17 00:00:00 2001 From: sbosse Date: Mon, 14 Oct 2024 23:09:42 +0200 Subject: [PATCH] Mon 14 Oct 23:09:15 CEST 2024 --- user/test/exectest.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 user/test/exectest.c diff --git a/user/test/exectest.c b/user/test/exectest.c new file mode 100644 index 0000000..85112a2 --- /dev/null +++ b/user/test/exectest.c @@ -0,0 +1,20 @@ +#include "library/syscalls.h" +#include "library/string.h" + +int main(int argc, char *argv[]) +{ + int pid = syscall_process_fork(); + + if (pid == 0) { + printf("hello world, I am the child %d.\n", syscall_process_self()); + const char *args[] = { "snake.exe" }; + syscall_process_exec("snake.exe", 1, args); + } else { + printf("hello world, I am the parent %d.\n", syscall_process_self()); + struct process_info info; + syscall_process_wait(&info, -1); + syscall_process_reap(info.pid); + } + + return 0; +}