Module Name:    src
Committed By:   bouyer
Date:           Sat Mar 17 19:14:15 UTC 2012

Modified Files:
        src/sys/kern [netbsd-5-0]: kern_sig.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1741):
        sys/kern/kern_sig.c: revision 1.300
kpsignal2: do not make the signal pending twice when tracing the process,
also update a comment and add an assert.  Fixes PR/42309 by Nicolas Joly.


To generate a diff of this commit:
cvs rdiff -u -r1.289.4.5.2.1 -r1.289.4.5.2.2 src/sys/kern/kern_sig.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_sig.c
diff -u src/sys/kern/kern_sig.c:1.289.4.5.2.1 src/sys/kern/kern_sig.c:1.289.4.5.2.2
--- src/sys/kern/kern_sig.c:1.289.4.5.2.1	Sat Jan 16 17:32:45 2010
+++ src/sys/kern/kern_sig.c	Sat Mar 17 19:14:15 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.289.4.5.2.1 2010/01/16 17:32:45 bouyer Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.289.4.5.2.2 2012/03/17 19:14:15 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.289.4.5.2.1 2010/01/16 17:32:45 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.289.4.5.2.2 2012/03/17 19:14:15 bouyer Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_compat_sunos.h"
@@ -1382,15 +1382,13 @@ kpsignal2(struct proc *p, ksiginfo_t *ks
 			goto out;
 	} else {
 		/*
-		 * Process is stopped or stopping.  If traced, then no
-		 * further action is necessary.
+		 * Process is stopped or stopping.
+		 * - If traced, then no action is needed, unless killing.
+		 * - Run the process only if sending SIGCONT or SIGKILL.
 		 */
-		if ((p->p_slflag & PSL_TRACED) != 0 && signo != SIGKILL)
+		if ((p->p_slflag & PSL_TRACED) != 0 && signo != SIGKILL) {
 			goto out;
-
-		/*
-		 * Run the process only if sending SIGCONT or SIGKILL.
-		 */
+		}
 		if ((prop & SA_CONT) != 0 || signo == SIGKILL) {
 			/*
 			 * Re-adjust p_nstopchild if the process wasn't
@@ -1398,9 +1396,13 @@ kpsignal2(struct proc *p, ksiginfo_t *ks
 			 */
 			p->p_stat = SACTIVE;
 			p->p_sflag &= ~PS_STOPPING;
-			if (!p->p_waited)
+			if (!p->p_waited) {
 				p->p_pptr->p_nstopchild--;
-
+			}
+			if (p->p_slflag & PSL_TRACED) {
+				KASSERT(signo == SIGKILL);
+				goto deliver;
+			}
 			/*
 			 * Do not make signal pending if SIGCONT is default.
 			 *
@@ -1423,6 +1425,7 @@ kpsignal2(struct proc *p, ksiginfo_t *ks
 	/*
 	 * Make signal pending.
 	 */
+	KASSERT((p->p_slflag & PSL_TRACED) == 0);
 	sigput(&p->p_sigpend, p, kp);
 
  deliver:

Reply via email to