diff options
author | Ian Moffett <ian@osmora.org> | 2024-03-07 17:28:00 -0500 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-03-07 17:28:32 -0500 |
commit | bd5969fc876a10b18613302db7087ef3c40f18e1 (patch) | |
tree | 7c2b8619afe902abf99570df2873fbdf40a4d1a1 /lib/mlibc/options/posix/generic/sys-wait-stubs.cpp | |
parent | a95b38b1b92b172e6cc4e8e56a88a30cc65907b0 (diff) |
lib: Add mlibc
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/options/posix/generic/sys-wait-stubs.cpp')
-rw-r--r-- | lib/mlibc/options/posix/generic/sys-wait-stubs.cpp | 52 |
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; +} |