about summary refs log tree commit diff
path: root/sysdeps/mach/hurd/wait4.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach/hurd/wait4.c')
-rw-r--r--sysdeps/mach/hurd/wait4.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/sysdeps/mach/hurd/wait4.c b/sysdeps/mach/hurd/wait4.c
index 0b505ba0d8..db6b8c021f 100644
--- a/sysdeps/mach/hurd/wait4.c
+++ b/sysdeps/mach/hurd/wait4.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
+/* Copyright (C) 1993,94,95,96,97,98,99 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -35,8 +35,21 @@ __wait4 (pid_t pid, __WAIT_STATUS_DEFN stat_loc, int options,
   err = __USEPORT (PROC, __proc_wait (port, pid, options,
 				      stat_loc ?: &dummy, &sigcode,
 				      usage ?: &ignored, &dead));
-
-  return err ? (pid_t) __hurd_fail (err) : dead;
+  switch (err)
+    {
+    case 0:			/* Got a child.  */
+      return dead;
+    case EAGAIN:
+      /* The RPC returns this error when the WNOHANG flag is set and no
+	 selected children are dead (but some are living).  In that
+	 situation, our return value is zero.  (The RPC can't return zero
+	 for DEAD without also returning some garbage for the other out
+	 parameters, so an error return is much more natural here.  Hence
+	 the difference between the RPC and the POSIX.1 interface.  */
+      return (pid_t) 0;
+    default:
+      return (pid_t) __hurd_fail (err);
+    }
 }
 
 weak_alias (__wait4, wait4)