telnet line mode changes
[unix-history] / usr / src / sys / kern / kern_exit.c
index 664595a..4f7b509 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)kern_exit.c 7.13 (Berkeley) %G%
+ *     @(#)kern_exit.c 7.19 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -63,7 +63,7 @@ exit(rv)
 {
        register int i;
        register struct proc *p, *q, *nq;
 {
        register int i;
        register struct proc *p, *q, *nq;
-       register int x;
+       register struct proc **pp;
 
 #ifdef PGINPROF
        vmsizmon();
 
 #ifdef PGINPROF
        vmsizmon();
@@ -85,9 +85,13 @@ exit(rv)
         * a vfork(), instead give the resources back to
         * the parent.
         */
         * a vfork(), instead give the resources back to
         * the parent.
         */
-       if ((p->p_flag & SVFORK) == 0)
+       if ((p->p_flag & SVFORK) == 0) {
+#ifdef MAPMEM
+               if (u.u_mmap)
+                       mmexit();
+#endif
                vrelvm();
                vrelvm();
-       else {
+       else {
                p->p_flag &= ~SVFORK;
                wakeup((caddr_t)p);
                while ((p->p_flag & SVFDONE) == 0)
                p->p_flag &= ~SVFORK;
                wakeup((caddr_t)p);
                while ((p->p_flag & SVFDONE) == 0)
@@ -110,7 +114,10 @@ exit(rv)
                        vgoneall(p->p_session->s_ttyvp);
                        vrele(p->p_session->s_ttyvp);
                        p->p_session->s_ttyvp = NULL;
                        vgoneall(p->p_session->s_ttyvp);
                        vrele(p->p_session->s_ttyvp);
                        p->p_session->s_ttyvp = NULL;
-                       p->p_session->s_ttyp = NULL;
+                       /*
+                        * s_ttyp is not zero'd; we use this to indicate
+                        * that the session once had a controlling terminal.
+                        */
                }
        }
        VOP_LOCK(u.u_cdir);
                }
        }
        VOP_LOCK(u.u_cdir);
@@ -121,9 +128,6 @@ exit(rv)
        }
        u.u_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
        acct();
        }
        u.u_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
        acct();
-#ifdef QUOTA
-       qclean();
-#endif
        crfree(u.u_cred);
 #ifdef KTRACE
        /* 
        crfree(u.u_cred);
 #ifdef KTRACE
        /* 
@@ -132,7 +136,6 @@ exit(rv)
        if (p->p_tracep)
                vrele(p->p_tracep);
 #endif
        if (p->p_tracep)
                vrele(p->p_tracep);
 #endif
-       /*
        /*
         * Freeing the user structure and kernel stack
         * for the current process: have to run a bit longer
        /*
         * Freeing the user structure and kernel stack
         * for the current process: have to run a bit longer
@@ -150,18 +153,13 @@ exit(rv)
        multprog--;
        p->p_stat = SZOMB;
        noproc = 1;
        multprog--;
        p->p_stat = SZOMB;
        noproc = 1;
-       i = PIDHASH(p->p_pid);
-       x = p - proc;
-       if (pidhash[i] == x)
-               pidhash[i] = p->p_idhash;
-       else {
-               for (i = pidhash[i]; i != 0; i = proc[i].p_idhash)
-                       if (proc[i].p_idhash == x) {
-                               proc[i].p_idhash = p->p_idhash;
-                               goto done;
-                       }
-               panic("exit");
-       }
+       for (pp = &pidhash[PIDHASH(p->p_pid)]; *pp; pp = &(*pp)->p_hash)
+               if (*pp == p) {
+                       *pp = p->p_hash;
+                       goto done;
+               }
+       panic("exit");
+done:
        if (p->p_pid == 1) {
                if (p->p_dsize == 0) {
                        printf("Can't exec init (errno %d)\n", WEXITSTATUS(rv));
        if (p->p_pid == 1) {
                if (p->p_dsize == 0) {
                        printf("Can't exec init (errno %d)\n", WEXITSTATUS(rv));
@@ -170,9 +168,12 @@ exit(rv)
                } else
                        panic("init died");
        }
                } else
                        panic("init died");
        }
-done:
        p->p_xstat = rv;
        *p->p_ru = u.u_ru;
        p->p_xstat = rv;
        *p->p_ru = u.u_ru;
+       i = splclock();
+       p->p_ru->ru_stime = p->p_stime;
+       p->p_ru->ru_utime = p->p_utime;
+       splx(i);
        ruadd(p->p_ru, &u.u_cru);
        if (p->p_cptr)          /* only need this if any child is S_ZOMB */
                wakeup((caddr_t)&proc[1]);
        ruadd(p->p_ru, &u.u_cru);
        if (p->p_cptr)          /* only need this if any child is S_ZOMB */
                wakeup((caddr_t)&proc[1]);
@@ -374,13 +375,7 @@ loop:
                u.u_r.r_val1 = 0;
                return (0);
        }
                u.u_r.r_val1 = 0;
                return (0);
        }
-       if (setjmp(&u.u_qsave)) {
-               p = u.u_procp;
-               if ((u.u_sigintr & sigmask(p->p_cursig)) != 0)
-                       return (EINTR);
-               u.u_eosys = RESTARTSYS;
-               return (0);
-       }
-       sleep((caddr_t)u.u_procp, PWAIT);
+       if (error = tsleep((caddr_t)u.u_procp, PWAIT | PCATCH, "wait", 0))
+               return (error);
        goto loop;
 }
        goto loop;
 }