]>
Commit | Line | Data |
---|---|---|
1f2f436a A |
1 | --- waitpid.c.orig 2009-11-07 14:51:38.000000000 -0800 |
2 | +++ waitpid.c 2009-11-07 14:51:40.000000000 -0800 | |
3 | @@ -40,10 +40,31 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/wai | |
224c7076 A |
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); |