summaryrefslogtreecommitdiff
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-03-03 17:20:29 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-03-03 17:20:29 +0000
commita69a4a568209bb69852224e2cd6f6394ed4da746 (patch)
tree35d8778bf8e995cb348c0bb9d78d38b7a7e6e356 /sys/kern/kern_exit.c
parent5aeba8440e8d2256e4b716030f97e3bf493b725a (diff)
From NetBSD: 960217 merge
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index c696ac37c62..3c6a54e5d9f 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,5 @@
-/* $NetBSD: kern_exit.c,v 1.35 1995/12/24 11:23:33 mycroft Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.5 1996/03/03 17:19:44 niklas Exp $ */
+/* $NetBSD: kern_exit.c,v 1.38 1996/02/09 18:59:29 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -59,6 +60,15 @@
#include <sys/resourcevar.h>
#include <sys/ptrace.h>
#include <sys/acct.h>
+#include <sys/filedesc.h>
+#include <sys/signalvar.h>
+#ifdef SYSVSHM
+#include <sys/shm.h>
+#endif
+#ifdef SYSVSEM
+#include <sys/sem.h>
+#endif
+#include <sys/cpu.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
@@ -68,9 +78,6 @@
#include <vm/vm.h>
#include <vm/vm_kern.h>
-void cpu_exit __P((struct proc *)); /* XXX MOVE ME */
-void exit1 __P((struct proc *, int));
-
/*
* exit --
* Death of process.
@@ -114,11 +121,15 @@ exit1(p, rv)
MALLOC(p->p_ru, struct rusage *, sizeof(struct rusage),
M_ZOMBIE, M_WAITOK);
/*
- * If parent is waiting for us to exit or exec,
- * P_PPWAIT is set; we will wakeup the parent below.
+ * If parent is waiting for us to exit or exec, P_PPWAIT is set; we
+ * wake up the parent early to avoid deadlock.
*/
- p->p_flag &= ~(P_TRACED | P_PPWAIT);
p->p_flag |= P_WEXIT;
+ p->p_flag &= ~P_TRACED;
+ if (p->p_flag & P_PPWAIT) {
+ p->p_flag &= ~P_PPWAIT;
+ wakeup((caddr_t)p->p_pptr);
+ }
p->p_sigignore = ~0;
p->p_siglist = 0;
untimeout(realitexpire, (caddr_t)p);
@@ -205,7 +216,7 @@ exit1(p, rv)
q = p->p_children.lh_first;
if (q) /* only need this if any child is S_ZOMB */
- wakeup((caddr_t) initproc);
+ wakeup((caddr_t)initproc);
for (; q != 0; q = nq) {
nq = q->p_sibling.le_next;
proc_reparent(q, initproc);
@@ -253,7 +264,8 @@ exit1(p, rv)
* Other substructures are freed from wait().
*/
curproc = NULL;
- limfree(p->p_limit);
+ if (--p->p_limit->p_refcnt == 0)
+ FREE(p->p_limit, M_SUBPROC);
/*
* Finally, call machine-dependent code to release the remaining
@@ -306,9 +318,10 @@ loop:
if (SCARG(uap, status)) {
status = p->p_xstat; /* convert to int */
- if (error = copyout((caddr_t)&status,
- (caddr_t)SCARG(uap, status),
- sizeof(status)))
+ error = copyout((caddr_t)&status,
+ (caddr_t)SCARG(uap, status),
+ sizeof(status));
+ if (error)
return (error);
}
if (SCARG(uap, rusage) &&
@@ -389,7 +402,7 @@ loop:
retval[0] = 0;
return (0);
}
- if (error = tsleep((caddr_t)q, PWAIT | PCATCH, "wait", 0))
+ if ((error = tsleep((caddr_t)q, PWAIT | PCATCH, "wait", 0)) != 0)
return (error);
goto loop;
}