diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2008-05-11 23:54:41 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2008-05-11 23:54:41 +0000 |
commit | 99517932c1dd75b4a71a9be65c772b461e9fd22e (patch) | |
tree | 961f7e2b8be64881840907cd2811e87d386323c9 | |
parent | 0a6f1054c54effa68d99f9a6e57a4915ca1301e9 (diff) |
set p_flag to 0 sooner, so we don't overwrite the thread flag. and correctly
free things when exiting a threaded proc. from philip guenther
-rw-r--r-- | sys/kern/kern_exit.c | 8 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 4 |
2 files changed, 5 insertions, 7 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index fa68a37f72a..c6dc7cf0cdf 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.72 2007/10/10 15:53:53 art Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.73 2008/05/11 23:54:40 tedu Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -590,10 +590,8 @@ proc_zap(struct proc *p) * Remove us from our process list, possibly killing the process * in the process (pun intended). */ -#if 0 - TAILQ_REMOVE(&p->p_p->ps_threads, p, p_thr_link); -#endif - if (TAILQ_EMPTY(&p->p_p->ps_threads)) { + if ((p->p_flag & P_THREAD) == 0) { + KASSERT(TAILQ_EMPTY(&p->p_p->ps_threads)); limfree(p->p_p->ps_limit); if (--p->p_p->ps_cred->p_refcnt == 0) { crfree(p->p_p->ps_cred->pc_ucred); diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 7c741157d81..a7ba5624565 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.94 2008/05/11 23:50:32 tedu Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.95 2008/05/11 23:54:40 tedu Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -224,6 +224,7 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, p2->p_stat = SIDL; /* protect against others */ p2->p_exitsig = exitsig; + p2->p_flag = 0; #ifdef RTHREADS if (flags & FORK_THREAD) { @@ -260,7 +261,6 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, * Increase reference counts on shared objects. * The p_stats and p_sigacts substructs are set in vm_fork. */ - p2->p_flag = 0; p2->p_emul = p1->p_emul; if (p1->p_flag & P_PROFIL) startprofclock(p2); |