summaryrefslogtreecommitdiff
path: root/src/sys/os
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-10-13 16:14:02 -0400
committerIan Moffett <ian@osmora.org>2025-10-13 16:14:02 -0400
commitb61c07af798557eff4333716c917c99a4f0c13c6 (patch)
treed48c14f901fbabe0e114f91840aa6406c0623c79 /src/sys/os
parent44bbb86a75043b38bdfb9ed6ff4be0764e3fc905 (diff)
kern: proc: Add initial waitpid() syscall
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/os')
-rw-r--r--src/sys/os/os_proc.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/sys/os/os_proc.c b/src/sys/os/os_proc.c
index 4ee4fd8..764b3f2 100644
--- a/src/sys/os/os_proc.c
+++ b/src/sys/os/os_proc.c
@@ -439,3 +439,35 @@ sys_getargv(struct syscall_args *scargs)
arg = envblk->argv[argno];
return copyoutstr(arg, u_buf, maxlen);
}
+
+/*
+ * Wait for a child to complete
+ *
+ * ARG0: PID
+ * ARG1: Status
+ * ARG2: Options
+ */
+scret_t
+sys_waitpid(struct syscall_args *scargs)
+{
+ int pid = SCARG(scargs, int, 0);
+ int *u_status = SCARG(scargs, int *, 1);
+ int status = 0;
+ int error = 0;
+ struct proc *proc, *self;
+
+ if ((proc = proc_lookup(pid)) == NULL) {
+ return -ESRCH;
+ }
+
+ if (u_status != NULL) {
+ error = copyout(&status, u_status, sizeof(*u_status));
+ }
+ if (error < 0) {
+ return error;
+ }
+
+ self = proc_self();
+ proc_sleep(self);
+ return 0;
+}