| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_sig.c,v 1.289.4.8 2012/03/17 19:14:08 bouyer Exp $ */ | | 1 | /* $NetBSD: kern_sig.c,v 1.289.4.8.2.1 2015/11/07 20:47:08 snj Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Andrew Doran. | | 8 | * by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -56,27 +56,27 @@ | | | @@ -56,27 +56,27 @@ |
56 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 56 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
57 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 57 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
58 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 58 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
59 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 59 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
63 | * SUCH DAMAGE. | | 63 | * SUCH DAMAGE. |
64 | * | | 64 | * |
65 | * @(#)kern_sig.c 8.14 (Berkeley) 5/14/95 | | 65 | * @(#)kern_sig.c 8.14 (Berkeley) 5/14/95 |
66 | */ | | 66 | */ |
67 | | | 67 | |
68 | #include <sys/cdefs.h> | | 68 | #include <sys/cdefs.h> |
69 | __KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.289.4.8 2012/03/17 19:14:08 bouyer Exp $"); | | 69 | __KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.289.4.8.2.1 2015/11/07 20:47:08 snj Exp $"); |
70 | | | 70 | |
71 | #include "opt_ptrace.h" | | 71 | #include "opt_ptrace.h" |
72 | #include "opt_compat_sunos.h" | | 72 | #include "opt_compat_sunos.h" |
73 | #include "opt_compat_netbsd.h" | | 73 | #include "opt_compat_netbsd.h" |
74 | #include "opt_compat_netbsd32.h" | | 74 | #include "opt_compat_netbsd32.h" |
75 | #include "opt_pax.h" | | 75 | #include "opt_pax.h" |
76 | #include "opt_sa.h" | | 76 | #include "opt_sa.h" |
77 | | | 77 | |
78 | #define SIGPROP /* include signal properties table */ | | 78 | #define SIGPROP /* include signal properties table */ |
79 | #include <sys/param.h> | | 79 | #include <sys/param.h> |
80 | #include <sys/signalvar.h> | | 80 | #include <sys/signalvar.h> |
81 | #include <sys/proc.h> | | 81 | #include <sys/proc.h> |
82 | #include <sys/systm.h> | | 82 | #include <sys/systm.h> |
| @@ -1392,34 +1392,33 @@ kpsignal2(struct proc *p, ksiginfo_t *ks | | | @@ -1392,34 +1392,33 @@ kpsignal2(struct proc *p, ksiginfo_t *ks |
1392 | if ((prop & SA_CONT) != 0 && action == SIG_DFL) | | 1392 | if ((prop & SA_CONT) != 0 && action == SIG_DFL) |
1393 | goto out; | | 1393 | goto out; |
1394 | } else { | | 1394 | } else { |
1395 | /* | | 1395 | /* |
1396 | * Process is stopped or stopping. | | 1396 | * Process is stopped or stopping. |
1397 | * - If traced, then no action is needed, unless killing. | | 1397 | * - If traced, then no action is needed, unless killing. |
1398 | * - Run the process only if sending SIGCONT or SIGKILL. | | 1398 | * - Run the process only if sending SIGCONT or SIGKILL. |
1399 | */ | | 1399 | */ |
1400 | if ((p->p_slflag & PSL_TRACED) != 0 && signo != SIGKILL) { | | 1400 | if ((p->p_slflag & PSL_TRACED) != 0 && signo != SIGKILL) { |
1401 | goto out; | | 1401 | goto out; |
1402 | } | | 1402 | } |
1403 | if ((prop & SA_CONT) != 0 || signo == SIGKILL) { | | 1403 | if ((prop & SA_CONT) != 0 || signo == SIGKILL) { |
1404 | /* | | 1404 | /* |
1405 | * Re-adjust p_nstopchild if the process wasn't | | 1405 | * Re-adjust p_nstopchild if the process was |
1406 | * collected by its parent. | | 1406 | * stopped but not yet collected by its parent. |
1407 | */ | | 1407 | */ |
| | | 1408 | if (p->p_stat == SSTOP && !p->p_waited) |
| | | 1409 | p->p_pptr->p_nstopchild--; |
1408 | p->p_stat = SACTIVE; | | 1410 | p->p_stat = SACTIVE; |
1409 | p->p_sflag &= ~PS_STOPPING; | | 1411 | p->p_sflag &= ~PS_STOPPING; |
1410 | if (!p->p_waited) { | | | |
1411 | p->p_pptr->p_nstopchild--; | | | |
1412 | } | | | |
1413 | if (p->p_slflag & PSL_TRACED) { | | 1412 | if (p->p_slflag & PSL_TRACED) { |
1414 | KASSERT(signo == SIGKILL); | | 1413 | KASSERT(signo == SIGKILL); |
1415 | goto deliver; | | 1414 | goto deliver; |
1416 | } | | 1415 | } |
1417 | /* | | 1416 | /* |
1418 | * Do not make signal pending if SIGCONT is default. | | 1417 | * Do not make signal pending if SIGCONT is default. |
1419 | * | | 1418 | * |
1420 | * If the process catches SIGCONT, let it handle the | | 1419 | * If the process catches SIGCONT, let it handle the |
1421 | * signal itself (if waiting on event - process runs, | | 1420 | * signal itself (if waiting on event - process runs, |
1422 | * otherwise continues sleeping). | | 1421 | * otherwise continues sleeping). |
1423 | */ | | 1422 | */ |
1424 | if ((prop & SA_CONT) != 0 && action == SIG_DFL) { | | 1423 | if ((prop & SA_CONT) != 0 && action == SIG_DFL) { |
1425 | KASSERT(signo != SIGKILL); | | 1424 | KASSERT(signo != SIGKILL); |