From John Dyson - fix for bug in kern_physio where buffers would be
[unix-history] / sys / kern / kern_exit.c
index 34a8eb2..6109310 100644 (file)
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  *
  *     from: @(#)kern_exit.c   7.35 (Berkeley) 6/27/91
  * SUCH DAMAGE.
  *
  *     from: @(#)kern_exit.c   7.35 (Berkeley) 6/27/91
- *     $Id: kern_exit.c,v 1.11 1993/12/19 00:51:24 wollman Exp $
+ *     $Id: kern_exit.c,v 1.14 1994/01/29 04:04:23 davidg Exp $
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -158,7 +158,7 @@ kexit(p, rv)
                                (void) ttywait(sp->s_ttyp);
                                vgoneall(sp->s_ttyvp);
                        }
                                (void) ttywait(sp->s_ttyp);
                                vgoneall(sp->s_ttyvp);
                        }
-                       vrele(sp->s_ttyvp);
+                       vn_close(sp->s_ttyvp, FREAD, p->p_ucred, p);
                        sp->s_ttyvp = NULL;
                        /*
                         * s_ttyp is not zero'd; we use this to indicate
                        sp->s_ttyvp = NULL;
                        /*
                         * s_ttyp is not zero'd; we use this to indicate
@@ -175,19 +175,9 @@ kexit(p, rv)
         * release trace file
         */
        if (p->p_tracep)
         * release trace file
         */
        if (p->p_tracep)
-               vrele(p->p_tracep);
+               vn_close(p->p_tracep, FREAD|FWRITE, p->p_ucred, p);
 #endif
 
 #endif
 
-       /* current process does not exist, as far as other parts of the
-        * system (clock) is concerned, since parts of it might not be
-        * there anymore */
-       curproc = NULL;
-
-       if (--p->p_limit->p_refcnt == 0) {
-               FREE(p->p_limit, M_SUBPROC);
-               p->p_limit = (struct plimit *) -1;
-       }
-
        /*
         * Remove proc from allproc queue and pidhash chain.
         * Place onto zombproc.  Unlink from parent's child list.
        /*
         * Remove proc from allproc queue and pidhash chain.
         * Place onto zombproc.  Unlink from parent's child list.
@@ -250,6 +240,18 @@ done:
        /* move this to cpu_exit */
        p->p_addr->u_pcb.pcb_savacc.faddr = (float *)NULL;
 #endif
        /* move this to cpu_exit */
        p->p_addr->u_pcb.pcb_savacc.faddr = (float *)NULL;
 #endif
+       /*
+        * current process does not exist, as far as other parts of the
+        * system (clock) is concerned, since parts of it might not be
+        * there anymore
+        */
+       curproc = NULL;
+
+       if (--p->p_limit->p_refcnt == 0) {
+               FREE(p->p_limit, M_SUBPROC);
+               p->p_limit = (struct plimit *) -1;
+       }
+
        /*
         * Finally, call machine-dependent code to release the remaining
         * resources including address space, the kernel stack and pcb.
        /*
         * Finally, call machine-dependent code to release the remaining
         * resources including address space, the kernel stack and pcb.
@@ -351,6 +353,9 @@ loop:
                        continue;
                nfound++;
                if (p->p_stat == SZOMB) {
                        continue;
                nfound++;
                if (p->p_stat == SZOMB) {
+                       /* charge childs cpu usage to parent */
+                       if( curproc->p_pid != 1)
+                               curproc->p_cpu += p->p_cpu;
                        retval[0] = p->p_pid;
 #ifdef COMPAT_43
                        if (uap->compat)
                        retval[0] = p->p_pid;
 #ifdef COMPAT_43
                        if (uap->compat)