summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2013-06-03 22:35:16 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2013-06-03 22:35:16 +0000
commite0a515beec746313769345ada44b7ebc185aca8f (patch)
treeac56ea0c5206dfed1e8558983c91fe8f12a28e77
parent732ec0db520bbd8cb2e2defef9b7014b1468359c (diff)
When creating a thread, don't add it to the process's thread list
until it's fully built, so that it can't get a signal from realitexpire(), as seen by sthen@ and espie@ in ports builds. Exact bits moved down worked out with tedu@, ok deraadt@
-rw-r--r--sys/kern/kern_fork.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 5d3ee5312c6..378b367efe5 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.148 2013/06/03 16:55:22 guenther Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.149 2013/06/03 22:35:15 guenther Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -323,16 +323,7 @@ fork1(struct proc *curp, int exitsig, int flags, void *stack, pid_t *tidptr,
if (flags & FORK_THREAD) {
atomic_setbits_int(&p->p_flag, P_THREAD);
p->p_p = pr = curpr;
- TAILQ_INSERT_TAIL(&pr->ps_threads, p, p_thr_link);
pr->ps_refcnt++;
- /*
- * if somebody else wants to take us to single threaded mode,
- * count ourselves in.
- */
- if (pr->ps_single) {
- curpr->ps_singlecount++;
- atomic_setbits_int(&p->p_flag, P_SUSPSINGLE);
- }
} else {
process_new(p, curpr);
pr = p->p_p;
@@ -474,6 +465,16 @@ fork1(struct proc *curp, int exitsig, int flags, void *stack, pid_t *tidptr,
pr->ps_ptstat->pe_other_pid = curpr->ps_pid;
}
}
+ } else {
+ TAILQ_INSERT_TAIL(&pr->ps_threads, p, p_thr_link);
+ /*
+ * if somebody else wants to take us to single threaded mode,
+ * count ourselves in.
+ */
+ if (pr->ps_single) {
+ curpr->ps_singlecount++;
+ atomic_setbits_int(&p->p_flag, P_SUSPSINGLE);
+ }
}
#if NSYSTRACE > 0