OrionLibC
Barry Importing existing Orion LibC 03048a9 (3 years, 2 months ago)
diff --git a/sys/wait.c b/sys/wait.c
new file mode 100644
index 0000000..912712a
--- /dev/null
+++ b/sys/wait.c
@@ -0,0 +1,23 @@
+#include <sys/syscall.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+/* Wait for a process to change state */
+pid_t
+wait(int *wstatus)
+{
+ return waitpid(-1, wstatus, 0);
+}
+
+/* Wait for a specific process to change state */
+pid_t
+waitpid(pid_t pid, int *wstatus, int options)
+{
+ int ret;
+ asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_WAITPID),
+ "c" (3), "S" (&pid));
+ if (ret >= 0)
+ return ret;
+ errno = -ret;
+ return -1;
+}