summaryrefslogtreecommitdiff
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2000-06-06 18:50:33 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2000-06-06 18:50:33 +0000
commit066f1322e6f5b02bc451ed7fa0303626cf50ca64 (patch)
tree15b2f9919b78160fd6b18b83c2ea1cf5c92635b8 /sys/kern/kern_exit.c
parent011074ac17b59298d9a39622ac2c52addd594ccf (diff)
If the process is P_NOZOMBIE free it's resources in the reaper.
Noone will wait for it (because noone is allowed to wait for it).
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c89
1 files changed, 54 insertions, 35 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 853970f080a..cb2aea9696a 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.26 2000/06/05 14:55:16 art Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.27 2000/06/06 18:50:32 art Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -83,6 +83,8 @@
#include <uvm/uvm_extern.h>
#endif
+void proc_zap __P((struct proc *));
+
/*
* exit --
* Death of process.
@@ -379,11 +381,16 @@ reaper()
#endif
/* Process is now a true zombie. */
- p->p_stat = SZOMB;
-
- /* Wake up the parent so it can get exit status. */
- psignal(p->p_pptr, SIGCHLD);
- wakeup((caddr_t)p->p_pptr);
+ if ((p->p_flag & P_NOZOMBIE) == 0) {
+ p->p_stat = SZOMB;
+
+ /* Wake up the parent so it can get exit status. */
+ psignal(p->p_pptr, SIGCHLD);
+ wakeup((caddr_t)p->p_pptr);
+ } else {
+ /* Noone will wait for us. Just zap the process now */
+ proc_zap(p);
+ }
}
}
@@ -437,6 +444,7 @@ loop:
(caddr_t)SCARG(uap, rusage),
sizeof(struct rusage))))
return (error);
+
/*
* If we got the child via a ptrace 'attach',
* we need to give it back to the old parent.
@@ -452,37 +460,9 @@ loop:
scheduler_wait_hook(q, p);
p->p_xstat = 0;
ruadd(&q->p_stats->p_cru, p->p_ru);
- FREE(p->p_ru, M_ZOMBIE);
- /*
- * Finally finished with old proc entry.
- * Unlink it from its process group and free it.
- */
- leavepgrp(p);
- LIST_REMOVE(p, p_list); /* off zombproc */
- LIST_REMOVE(p, p_sibling);
-
- /*
- * Decrement the count of procs running with this uid.
- */
- (void)chgproccnt(p->p_cred->p_ruid, -1);
+ proc_zap(p);
- /*
- * Free up credentials.
- */
- if (--p->p_cred->p_refcnt == 0) {
- crfree(p->p_cred->pc_ucred);
- FREE(p->p_cred, M_SUBPROC);
- }
-
- /*
- * Release reference to text vnode
- */
- if (p->p_textvp)
- vrele(p->p_textvp);
-
- FREE(p, M_PROC);
- nprocs--;
return (0);
}
if (p->p_stat == SSTOP && (p->p_flag & P_WAITED) == 0 &&
@@ -527,3 +507,42 @@ proc_reparent(child, parent)
LIST_INSERT_HEAD(&parent->p_children, child, p_sibling);
child->p_pptr = parent;
}
+
+void
+proc_zap(p)
+ struct proc *p;
+{
+
+ FREE(p->p_ru, M_ZOMBIE);
+
+ /*
+ * Finally finished with old proc entry.
+ * Unlink it from its process group and free it.
+ */
+ leavepgrp(p);
+ LIST_REMOVE(p, p_list); /* off zombproc */
+ LIST_REMOVE(p, p_sibling);
+
+ /*
+ * Decrement the count of procs running with this uid.
+ */
+ (void)chgproccnt(p->p_cred->p_ruid, -1);
+
+ /*
+ * Free up credentials.
+ */
+ if (--p->p_cred->p_refcnt == 0) {
+ crfree(p->p_cred->pc_ucred);
+ FREE(p->p_cred, M_SUBPROC);
+ }
+
+ /*
+ * Release reference to text vnode
+ */
+ if (p->p_textvp)
+ vrele(p->p_textvp);
+
+ FREE(p, M_PROC);
+ nprocs--;
+}
+