Copy-edit NEWS and fixup ChangeLog entries.
[glibc.git] / sysdeps / mach / hurd / wait4.c
blob6fd28ccfa950ab1ecc60c9abe0c7f64372c31e26
1 /* Copyright (C) 1993-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #include <sys/types.h>
19 #include <sys/wait.h>
20 #include <errno.h>
21 #include <hurd.h>
22 #include <hurd/port.h>
24 pid_t
25 __wait4 (pid_t pid, __WAIT_STATUS_DEFN stat_loc, int options,
26 struct rusage *usage)
28 pid_t dead;
29 error_t err;
30 struct rusage ignored;
31 int sigcode;
32 int dummy;
34 err = __USEPORT (PROC, __proc_wait (port, pid, options,
35 stat_loc ?: &dummy, &sigcode,
36 usage ?: &ignored, &dead));
37 switch (err)
39 case 0: /* Got a child. */
40 return dead;
41 case EAGAIN:
42 /* The RPC returns this error when the WNOHANG flag is set and no
43 selected children are dead (but some are living). In that
44 situation, our return value is zero. (The RPC can't return zero
45 for DEAD without also returning some garbage for the other out
46 parameters, so an error return is much more natural here. Hence
47 the difference between the RPC and the POSIX.1 interface. */
48 return (pid_t) 0;
49 default:
50 return (pid_t) __hurd_fail (err);
54 weak_alias (__wait4, wait4)