Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/nathanw_sa]: src/sys/kern Special-case the situation where all non-dead ...



details:   https://anonhg.NetBSD.org/src/rev/fc9349a6b6ba
branches:  nathanw_sa
changeset: 506065:fc9349a6b6ba
user:      nathanw <nathanw%NetBSD.org@localhost>
date:      Fri Jul 26 01:25:07 2002 +0000

description:
Special-case the situation where all non-dead LWPs in a process are suspended,
so that kill -9 succeeds.

diffstat:

 sys/kern/kern_sig.c |  35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 deletions(-)

diffs (81 lines):

diff -r 33257261aec1 -r fc9349a6b6ba sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c       Fri Jul 26 01:22:24 2002 +0000
+++ b/sys/kern/kern_sig.c       Fri Jul 26 01:25:07 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig.c,v 1.112.2.19 2002/07/17 19:54:30 nathanw Exp $      */
+/*     $NetBSD: kern_sig.c,v 1.112.2.20 2002/07/26 01:25:07 nathanw Exp $      */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.112.2.19 2002/07/17 19:54:30 nathanw Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.112.2.20 2002/07/26 01:25:07 nathanw Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_compat_sunos.h"
@@ -746,9 +746,9 @@
 psignal1(struct proc *p, int signum,
        int dolock)             /* XXXSMP: works, but icky */
 {
-       struct lwp      *l;
+       struct lwp      *l, *suspended;
 
-       int             s, prop;
+       int             s, prop, allsusp;
        sig_t           action;
 
 #ifdef DIAGNOSTIC
@@ -833,17 +833,27 @@
                goto out;
        } else {
                /* Process is sleeping or stopped */
-               /* Find out if any of the sleeps are interruptable */
                if (p->p_flag & P_SA) {
                        KDASSERT(p->p_sa->sa_idle != NULL);
                        l = p->p_sa->sa_idle;
                } else {
+                       /*
+                        * Find out if any of the sleeps are interruptable,
+                        * and if all the live LWPs remaining are suspended.
+                        */
+                       allsusp = 1;
                        for (l = LIST_FIRST(&p->p_lwps); 
                             l != NULL; 
-                            l = LIST_NEXT(l, l_sibling))
+                            l = LIST_NEXT(l, l_sibling)) {
                                if (l->l_stat == LSSLEEP && 
                                    l->l_flag & L_SINTR)
                                        break;
+                               if (l->l_stat == LSSUSPENDED)
+                                       suspended = l;
+                               else if ((l->l_stat != LSZOMB) && 
+                                        (l->l_stat != LSDEAD))
+                                       allsusp = 0;
+                       }
                }
                if (p->p_stat == SACTIVE) {
                        /* All LWPs must be sleeping */
@@ -885,9 +895,18 @@
                                goto out;
                        }
 
-                       if (l == NULL)
+                       if (l == NULL) {
+                               /*
+                                * Special case: SIGKILL of a process
+                                * which is entirely composed of
+                                * suspended LWPs should succeed. We
+                                * make this happen by unsuspending one of
+                                * them.
+                                */
+                               if (allsusp && (signum == SIGKILL))
+                                       lwp_continue(suspended);
                                goto out;
-
+                       }
                        /*
                         * All other (caught or default) signals
                         * cause the process to run.



Home | Main Index | Thread Index | Old Index