diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-10-06 08:56:48 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-10-06 08:56:48 +0000 |
commit | 17f83c4e08b9c092c51087adc4b23faba914da8d (patch) | |
tree | 966635688684c3a38f9db8c6e620f1acc1f920ea | |
parent | f73561de4c3283df10a7eb15a85efef8149312aa (diff) |
- Fallback waitid impl (Peter S. Mazinger)
-rw-r--r-- | libc/sysdeps/linux/common/waitid.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/libc/sysdeps/linux/common/waitid.c b/libc/sysdeps/linux/common/waitid.c index b8d2f70ba..ce3d5dc05 100644 --- a/libc/sysdeps/linux/common/waitid.c +++ b/libc/sysdeps/linux/common/waitid.c @@ -5,12 +5,47 @@ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ -#include <sys/syscall.h> +#include <features.h> #if defined __USE_SVID || defined __USE_XOPEN -#include <unistd.h> -#include <sys/types.h> -#include <sys/wait.h> +# include <sys/types.h> +# include <sys/wait.h> +# include <sys/syscall.h> +# ifdef __NR_waitid +_syscall4(int, waitid, idtype_t, idtype, id_t, id, siginfo_t*, infop, int, options) +# else +# include <string.h> +libc_hidden_proto(waitpid) +int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options) +{ + switch (idtype) { + case P_PID: + if (id <= 0) + goto invalid; + break; + case P_PGID: + if (id < 0 || id == 1) + goto invalid; + id = -id; + break; + case P_ALL: + id = -1; + break; + default: + invalid: + __set_errno(EINVAL); + return -1; + } -_syscall4(int, waitid, idtype_t, idtype, id_t, id, siginfo_t*, infop, int, options); + memset(infop, 0, sizeof *infop); + infop->si_pid = waitpid(id, &infop->si_status, options +# ifdef WEXITED + &~ WEXITED +# endif + ); + if (infop->si_pid < 0) + return infop->si_pid; + return 0; +} +# endif #endif |