]> git.saurik.com Git - apple/libc.git/blob - gen/FreeBSD/waitpid.c.patch
Libc-594.1.4.tar.gz
[apple/libc.git] / gen / FreeBSD / waitpid.c.patch
1 --- waitpid.c.orig 2006-09-16 19:12:38.000000000 -0700
2 +++ waitpid.c 2006-09-16 20:38:56.000000000 -0700
3 @@ -44,10 +44,31 @@
4 #include <sys/resource.h>
5 #include "un-namespace.h"
6
7 +#if __DARWIN_UNIX03
8 +#include <errno.h>
9 +#endif /* __DARWIN_UNIX03 */
10 +#ifdef VARIANT_CANCELABLE
11 +int __wait4(pid_t, int *, int , struct rusage *);
12 +#else /* !VARIANT_CANCELABLE */
13 +int __wait4_nocancel(pid_t, int *, int , struct rusage *);
14 +#endif /* VARIANT_CANCELABLE */
15 +
16 pid_t
17 __waitpid(pid_t pid, int *istat, int options)
18 {
19 - return (_wait4(pid, istat, options, (struct rusage *)0));
20 +#if __DARWIN_UNIX03
21 + /* POSIX: Validate waitpid() options before calling wait4() */
22 + if ((options & (WCONTINUED | WNOHANG | WUNTRACED)) != options) {
23 + errno = EINVAL;
24 + return ((pid_t)-1);
25 + }
26 +#endif /* __DARWIN_UNIX03 */
27 +
28 +#ifdef VARIANT_CANCELABLE
29 + return (__wait4(pid, istat, options, (struct rusage *)0));
30 +#else /* !VARIANT_CANCELABLE */
31 + return (__wait4_nocancel(pid, istat, options, (struct rusage *)0));
32 +#endif /* VARIANT_CANCELABLE */
33 }
34
35 __weak_reference(__waitpid, waitpid);