aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/posix/generic/sys-wait-stubs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mlibc/options/posix/generic/sys-wait-stubs.cpp')
-rw-r--r--lib/mlibc/options/posix/generic/sys-wait-stubs.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/mlibc/options/posix/generic/sys-wait-stubs.cpp b/lib/mlibc/options/posix/generic/sys-wait-stubs.cpp
new file mode 100644
index 0000000..6e7cc78
--- /dev/null
+++ b/lib/mlibc/options/posix/generic/sys-wait-stubs.cpp
@@ -0,0 +1,52 @@
+
+#include <errno.h>
+#include <sys/wait.h>
+#include <bits/ensure.h>
+
+#include <mlibc/ansi-sysdeps.hpp>
+#include <mlibc/posix-sysdeps.hpp>
+#include <mlibc/debug.hpp>
+
+int waitid(idtype_t idtype, id_t id, siginfo_t *info, int options) {
+ auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_waitid, -1);
+ if(int e = sysdep(idtype, id, info, options); e) {
+ errno = e;
+ return -1;
+ }
+ return 0;
+}
+
+pid_t waitpid(pid_t pid, int *status, int flags) {
+ pid_t ret;
+ int tmp_status = 0;
+ MLIBC_CHECK_OR_ENOSYS(mlibc::sys_waitpid, -1);
+ if(int e = mlibc::sys_waitpid(pid, &tmp_status, flags, NULL, &ret); e) {
+ errno = e;
+ return -1;
+ }
+ if(status) {
+ *status = tmp_status;
+ }
+ return ret;
+}
+
+pid_t wait(int *status) {
+ return waitpid(-1, status, 0);
+}
+
+pid_t wait3(int *status, int options, struct rusage *rusage) {
+ (void) rusage;
+ mlibc::infoLogger() << "\e[31mmlibc: wait3() is not implemented correctly\e[39m"
+ << frg::endlog;
+ return waitpid(-1, status, options);
+}
+
+pid_t wait4(pid_t pid, int *status, int options, struct rusage *ru) {
+ pid_t ret;
+ MLIBC_CHECK_OR_ENOSYS(mlibc::sys_waitpid, -1);
+ if(int e = mlibc::sys_waitpid(pid, status, options, ru, &ret); e) {
+ errno = e;
+ return -1;
+ }
+ return ret;
+}