Module Name:    src
Committed By:   christos
Date:           Tue Apr  5 14:07:31 UTC 2016

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

Log Message:
Simplify even more to make it clear how the status is set.


To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 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.254 src/sys/kern/kern_exit.c:1.255
--- src/sys/kern/kern_exit.c:1.254	Tue Apr  5 09:01:46 2016
+++ src/sys/kern/kern_exit.c	Tue Apr  5 10:07:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exit.c,v 1.254 2016/04/05 13:01:46 christos Exp $	*/
+/*	$NetBSD: kern_exit.c,v 1.255 2016/04/05 14:07:31 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.254 2016/04/05 13:01:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.255 2016/04/05 14:07:31 christos Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -119,7 +119,7 @@ int debug_exit = 0;
 #endif
 
 static int find_stopped_child(struct proc *, idtype_t, id_t, int,
-    struct proc **, int *, struct wrusage *, siginfo_t *);
+    struct proc **, struct wrusage *, siginfo_t *);
 static void proc_free(struct proc *, struct wrusage *);
 
 /*
@@ -665,7 +665,7 @@ do_sys_waitid(idtype_t idtype, id_t id, 
 		memset(si, 0, sizeof(*si));
 
 	mutex_enter(proc_lock);
-	error = find_stopped_child(curproc, idtype, id, options, &child, status,
+	error = find_stopped_child(curproc, idtype, id, options, &child,
 	    wru, si);
 	if (child == NULL) {
 		mutex_exit(proc_lock);
@@ -675,6 +675,8 @@ do_sys_waitid(idtype_t idtype, id_t id, 
 	*pid = child->p_pid;
 
 	if (child->p_stat == SZOMB) {
+		/* Child is exiting */
+		*status = P_WAITSTATUS(child);
 		/* proc_free() will release the proc_lock. */
 		if (options & WNOWAIT) {
 			mutex_exit(proc_lock);
@@ -683,8 +685,8 @@ do_sys_waitid(idtype_t idtype, id_t id, 
 		}
 	} else {
 		/* Child state must have been SSTOP. */
+		*status = W_STOPCODE(child->p_xsig);
 		mutex_exit(proc_lock);
-		*status = W_STOPCODE(*status);
 	}
 	return 0;
 }
@@ -918,7 +920,7 @@ match_process(struct proc *pp, struct pr
  */
 static int
 find_stopped_child(struct proc *parent, idtype_t idtype, id_t id, int options,
-    struct proc **child_p, int *status_p, struct wrusage *wru, siginfo_t *si)
+    struct proc **child_p, struct wrusage *wru, siginfo_t *si)
 {
 	struct proc *child, *dead;
 	int error;
@@ -1034,9 +1036,6 @@ find_stopped_child(struct proc *parent, 
 
 		if (child != NULL || error != 0 ||
 		    ((options & WNOHANG) != 0 && dead == NULL)) {
-		    	if (child != NULL) {
-			    	*status_p = P_WAITSTATUS(child);
-			}
 			*child_p = child;
 			return error;
 		}

Reply via email to