[Midnightbsd-cvs] src [8839] trunk/sys/kern: ignore stop adn continue signals sent to an existing process.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Mon Sep 26 00:05:53 EDT 2016


Revision: 8839
          http://svnweb.midnightbsd.org/src/?rev=8839
Author:   laffer1
Date:     2016-09-26 00:05:53 -0400 (Mon, 26 Sep 2016)
Log Message:
-----------
ignore stop adn continue signals sent to an existing process. stop signals set p_xstat to the sign that triggered

Modified Paths:
--------------
    trunk/sys/kern/kern_exit.c
    trunk/sys/kern/kern_sig.c

Modified: trunk/sys/kern/kern_exit.c
===================================================================
--- trunk/sys/kern/kern_exit.c	2016-09-26 04:04:34 UTC (rev 8838)
+++ trunk/sys/kern/kern_exit.c	2016-09-26 04:05:53 UTC (rev 8839)
@@ -200,6 +200,14 @@
 	_STOPEVENT(p, S_EXIT, rv);
 
 	/*
+	 * Ignore any pending request to stop due to a stop signal.
+	 * Once P_WEXIT is set, future requests will be ignored as
+	 * well.
+	 */
+	p->p_flag &= ~P_STOPPED_SIG;
+	KASSERT(!P_SHOULDSTOP(p), ("exiting process is stopped"));
+
+	/*
 	 * Note that we are exiting and do another wakeup of anyone in
 	 * PIOCWAIT in case they aren't listening for S_EXIT stops or
 	 * decided to wait again after we told them we are exiting.

Modified: trunk/sys/kern/kern_sig.c
===================================================================
--- trunk/sys/kern/kern_sig.c	2016-09-26 04:04:34 UTC (rev 8838)
+++ trunk/sys/kern/kern_sig.c	2016-09-26 04:05:53 UTC (rev 8839)
@@ -2142,6 +2142,8 @@
 	 * We try do the per-process part here.
 	 */
 	if (P_SHOULDSTOP(p)) {
+		KASSERT(!(p->p_flag & P_WEXIT),
+		    ("signal to stopped but exiting process"));
 		if (sig == SIGKILL) {
 			/*
 			 * If traced process is already stopped,
@@ -2256,7 +2258,7 @@
 		MPASS(action == SIG_DFL);
 
 		if (prop & SA_STOP) {
-			if (p->p_flag & P_PPWAIT)
+			if (p->p_flag & (P_PPWAIT|P_WEXIT))
 				goto out;
 			p->p_flag |= P_STOPPED_SIG;
 			p->p_xstat = sig;
@@ -2418,6 +2420,7 @@
 	struct proc *p = td->td_proc;
 
 	PROC_LOCK_ASSERT(p, MA_OWNED);
+	KASSERT(!(p->p_flag & P_WEXIT), ("Stopping exiting process"));
 	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
 	    &p->p_mtx.lock_object, "Stopping for traced signal");
 
@@ -2655,7 +2658,7 @@
 			 * process group, ignore tty stop signals.
 			 */
 			if (prop & SA_STOP) {
-				if (p->p_flag & P_TRACED ||
+				if (p->p_flag & (P_TRACED|P_WEXIT) ||
 		    		    (p->p_pgrp->pg_jobc == 0 &&
 				     prop & SA_TTYSTOP))
 					break;	/* == ignore */



More information about the Midnightbsd-cvs mailing list