]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/mach/hurd/wait4.c
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / mach / hurd / wait4.c
CommitLineData
d4697bc9 1/* Copyright (C) 1993-2014 Free Software Foundation, Inc.
ebbad4cc 2 This file is part of the GNU C Library.
28f540f4 3
ebbad4cc 4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
28f540f4 8
ebbad4cc
UD
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
41bdb6e2 12 Lesser General Public License for more details.
28f540f4 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
28f540f4 17
28f540f4
RM
18#include <sys/types.h>
19#include <sys/wait.h>
20#include <errno.h>
21#include <hurd.h>
22#include <hurd/port.h>
23
24pid_t
66715f83
UD
25__wait4 (pid_t pid, __WAIT_STATUS_DEFN stat_loc, int options,
26 struct rusage *usage)
28f540f4
RM
27{
28 pid_t dead;
29 error_t err;
30 struct rusage ignored;
b62b62ac 31 int sigcode;
ce7f605b 32 int dummy;
ebbad4cc
UD
33
34 err = __USEPORT (PROC, __proc_wait (port, pid, options,
ce7f605b 35 stat_loc ?: &dummy, &sigcode,
28f540f4 36 usage ?: &ignored, &dead));
50b076f4
RM
37 switch (err)
38 {
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);
51 }
28f540f4
RM
52}
53
54weak_alias (__wait4, wait4)