1 /* vi: set sw=4 ts=4: */
3 * Copyright (C) 2007 Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
10 #if defined __USE_SVID || defined __USE_XOPEN
12 # include <sys/types.h>
13 # include <sys/wait.h>
14 # include <sys/syscall.h>
18 # ifdef __UCLIBC_HAS_THREADS_NATIVE__
19 # include <sysdep-cancel.h>
21 # define SINGLE_THREAD_P 1
24 /* The waitid() POSIX interface takes 4 arguments, but the kernel function
25 * actually takes 5. The fifth is a pointer to struct rusage. Make sure
26 * we pass NULL rather than letting whatever was in the register bleed up.
28 #define __NR_waitid5 __NR_waitid
29 static __always_inline
30 _syscall5(int, waitid5, idtype_t, idtype, id_t, id, siginfo_t*, infop,
31 int, options, struct rusage*, ru)
34 int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options)
38 return waitid5(idtype, id, infop, options, NULL);
40 # ifdef __UCLIBC_HAS_THREADS_NATIVE__
41 int oldtype = LIBC_CANCEL_ASYNC ();
42 int result = waitid5(idtype, id, infop, options, NULL);
43 LIBC_CANCEL_RESET (oldtype);
47 # elif defined __NR_waitpid
54 if (id < 0 || id == 1)
67 memset(infop, 0, sizeof *infop);
68 infop->si_pid = waitpid(id, &infop->si_status, options
73 if (infop->si_pid < 0)