summaryrefslogtreecommitdiff
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>1999-02-19 19:21:43 +0000
committerArtur Grabowski <art@cvs.openbsd.org>1999-02-19 19:21:43 +0000
commite17845d92e4149a39aab4897917d41e3d4187242 (patch)
tree5fef00de807cdb4b6e3265418ab6a78ddd6c3ec6 /sys/kern/kern_fork.c
parent99dacef434ebe19354fe6d06d3c29fc66fa6635a (diff)
Allocate the u-area early in fork1 instead of in vm_fork.
Now we can return ENOMEM instead of doing a panic when we run out of memory.
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 92dade927dd..68a0e497a28 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.13 1999/01/11 20:25:09 niklas Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.14 1999/02/19 19:21:42 art Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -59,6 +59,7 @@
#include <sys/syscallargs.h>
#include <vm/vm.h>
+#include <vm/vm_kern.h>
int nprocs = 1; /* process 0 */
int randompid; /* when set to 1, pid's go random */
@@ -111,6 +112,18 @@ fork1(p1, forktype, rforkflags, retval)
int count;
static int pidchecked = 0;
int dupfd = 1, cleanfd = 0;
+ vm_offset_t uaddr;
+
+ /*
+ * Allocate a pcb and kernel stack for the process
+ */
+#if defined(arc) || defined(mips_cachealias)
+ uaddr = kmem_alloc_upage(kernel_map, USPACE);
+#else
+ uaddr = kmem_alloc_pageable(kernel_map, USPACE);
+#endif
+ if (uaddr == 0)
+ return ENOMEM;
if (forktype == ISRFORK) {
dupfd = 0;
@@ -291,6 +304,8 @@ again:
VM_INHERIT_SHARE);
}
+ p2->p_addr = (struct user *)uaddr;
+
#ifdef __FORK_BRAINDAMAGE
/*
* Set return values for child before vm_fork,