Module Name:    src
Committed By:   christos
Date:           Sat Nov  5 02:59:22 UTC 2016

Modified Files:
        src/sys/kern: kern_exit.c

Log Message:
Return 0 if WNOHANG and no kids.


To generate a diff of this commit:
cvs rdiff -u -r1.263 -r1.264 src/sys/kern/kern_exit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_exit.c
diff -u src/sys/kern/kern_exit.c:1.263 src/sys/kern/kern_exit.c:1.264
--- src/sys/kern/kern_exit.c:1.263	Fri Nov  4 14:14:04 2016
+++ src/sys/kern/kern_exit.c	Fri Nov  4 22:59:22 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exit.c,v 1.263 2016/11/04 18:14:04 christos Exp $	*/
+/*	$NetBSD: kern_exit.c,v 1.264 2016/11/05 02:59:22 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.263 2016/11/04 18:14:04 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.264 2016/11/05 02:59:22 christos Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -940,7 +940,7 @@ find_stopped_child(struct proc *parent, 
     struct proc **child_p, struct wrusage *wru, siginfo_t *si)
 {
 	struct proc *child, *dead;
-	int error;
+	int error, nohang;
 
 	KASSERT(mutex_owned(proc_lock));
 
@@ -969,6 +969,7 @@ find_stopped_child(struct proc *parent, 
 		idtype = P_PGID;
 	}
 
+	nohang = (options & WNOHANG) != 0;
 	for (;;) {
 		error = ECHILD;
 		dead = NULL;
@@ -1052,10 +1053,9 @@ find_stopped_child(struct proc *parent, 
 			}
 		}
 
-		if (child != NULL || error != 0 ||
-		    ((options & WNOHANG) != 0 && dead == NULL)) {
+		if (child != NULL || error != 0 || (nohang && dead == NULL)) {
 			*child_p = child;
-			return error;
+			return (nohang && error == ECHILD) ? 0 : error;
 		}
 
 		/*

Reply via email to