summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 70d883c..55324c6 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -287,6 +287,7 @@ fork1(p1, flags, procp)
* If RFHIGHPID is set (used during system boot), do not allocate
* low-numbered pids.
*/
+ lockmgr(&allproc_lock, LK_EXCLUSIVE, NULL, CURPROC);
trypid = nextpid + 1;
if (flags & RFHIGHPID) {
if (trypid < 10) {
@@ -343,12 +344,6 @@ again:
}
}
- p2 = newproc;
- p2->p_stat = SIDL; /* protect against others */
- p2->p_pid = trypid;
- LIST_INSERT_HEAD(&allproc, p2, p_list);
- LIST_INSERT_HEAD(PIDHASH(p2->p_pid), p2, p_hash);
-
/*
* RFHIGHPID does not mess with the nextpid counter during boot.
*/
@@ -357,6 +352,13 @@ again:
else
nextpid = trypid;
+ p2 = newproc;
+ p2->p_stat = SIDL; /* protect against others */
+ p2->p_pid = trypid;
+ LIST_INSERT_HEAD(&allproc, p2, p_list);
+ LIST_INSERT_HEAD(PIDHASH(p2->p_pid), p2, p_hash);
+ lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC);
+
/*
* Make a proc table entry for the new process.
* Start by zeroing the section of proc that is zero-initialized,
OpenPOWER on IntegriCloud