Tue Oct 13 00:27:19 2015 UTC ()
Currently, if a process is exiting and its parent has indicated no intent
of reaping the process (nor any other children), the process wil get
reparented to init.  Since the state of the exiting process at this point
is SDEAD, proc_reparent() will not update either the old or new parent's
p_nstopchild counters.

This change causes both old and new parents to be properly updated.

Fixes PR kern/50300

Pullups will be requested for:

       NetBSD-7, -6, -6-0, -6-1, -5, -5-0, -5-1, and -5-2


(pgoyette)
diff -r1.245 -r1.246 src/sys/kern/kern_exit.c

cvs diff -r1.245 -r1.246 src/sys/kern/kern_exit.c (expand / switch to context diff)
--- src/sys/kern/kern_exit.c 2015/10/02 16:54:15 1.245
+++ src/sys/kern/kern_exit.c 2015/10/13 00:27:19 1.246
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exit.c,v 1.245 2015/10/02 16:54:15 christos Exp $	*/
+/*	$NetBSD: kern_exit.c,v 1.246 2015/10/13 00:27:19 pgoyette 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.245 2015/10/02 16:54:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.246 2015/10/13 00:27:19 pgoyette Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -959,7 +959,7 @@
 	if (child->p_pptr == parent)
 		return;
 
-	if (child->p_stat == SZOMB ||
+	if (child->p_stat == SZOMB || child->p_stat == SDEAD ||
 	    (child->p_stat == SSTOP && !child->p_waited)) {
 		child->p_pptr->p_nstopchild--;
 		parent->p_nstopchild++;