diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-05-27 19:32:18 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-05-27 19:32:18 -0400 |
commit | a16022fc1e67009a89c2cbba253da3631286f235 (patch) | |
tree | 1d25d5ef973c93407c496c7ece64e97bd26dce1f /libc/sysdeps/linux/common/waitid.c | |
parent | b3eb972b9947e60f5b3d0135d8fbec19bb5d6a60 (diff) |
waitid: linux ABI takes 5 args, not 4
The POSIX waitid() takes 4 args, but the Linux one takes 5 args, so make
sure we stuff the 5th arg with a NULL. Otherwise garbage gets randomly
passed up and considering this is a pointer, that's baaaad.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libc/sysdeps/linux/common/waitid.c')
-rw-r--r-- | libc/sysdeps/linux/common/waitid.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/libc/sysdeps/linux/common/waitid.c b/libc/sysdeps/linux/common/waitid.c index 6218cdd53..b7930a02d 100644 --- a/libc/sysdeps/linux/common/waitid.c +++ b/libc/sysdeps/linux/common/waitid.c @@ -8,16 +8,27 @@ #include <features.h> #if defined __USE_SVID || defined __USE_XOPEN +# include <string.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> +/* The waitid() POSIX interface takes 4 arguments, but the kernel function + * actually takes 5. The fifth is a pointer to struct rusage. Make sure + * we pass NULL rather than letting whatever was in the register bleed up. + */ +#define __NR_waitid5 __NR_waitid +static _syscall5(int, waitid5, idtype_t, idtype, id_t, id, siginfo_t*, infop, + int, options, struct rusage*, ru) +# endif + /* libc_hidden_proto(waitpid) */ int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options) { +# ifdef __NR_waitid + return waitid5(idtype, id, infop, options, NULL); +# else switch (idtype) { case P_PID: if (id <= 0) @@ -46,6 +57,7 @@ int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options) if (infop->si_pid < 0) return infop->si_pid; return 0; -} # endif +} + #endif |