about summary refs log tree commit diff
path: root/sysdeps/mach/hurd/wait4.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-09-19 20:46:22 +0000
committerRoland McGrath <roland@gnu.org>1999-09-19 20:46:22 +0000
commit50b076f4ddf0b240ec90ff135bd31d9801366cac (patch)
tree627de8211fc17e85d55108063560eb3972108b6e /sysdeps/mach/hurd/wait4.c
parent55ffcab7b6e26b33fcb281aa70dc9abc33aa7ead (diff)
downloadglibc-50b076f4ddf0b240ec90ff135bd31d9801366cac.tar.gz
glibc-50b076f4ddf0b240ec90ff135bd31d9801366cac.tar.xz
glibc-50b076f4ddf0b240ec90ff135bd31d9801366cac.zip
1999-09-18 Roland McGrath <roland@baalperazim.frob.com>
	* sysdeps/mach/hurd/wait4.c (__wait4): When proc_wait returns EAGAIN,
	return zero to indicate no children died yet (assuming WNOHANG).

	* sysdeps/mach/hurd/setsid.c: #include <hurd/fd.h>.

1999-09-17  Roland McGrath  <roland@baalperazim.frob.com>

	* hurd/port2fd.c (_hurd_port2fd): Never change CTTYID port.

	* sysdeps/mach/hurd/setsid.c (__setsid): Fix return type -> pid_t.
	Return _hurd_pgrp instead of 0.
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)