summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordyson <dyson@FreeBSD.org>1996-03-03 19:48:45 +0000
committerdyson <dyson@FreeBSD.org>1996-03-03 19:48:45 +0000
commit112db21947e424c386cd9c5516fde237cc1d61d0 (patch)
tree6d121fd79868f94339d2b5305fddb8908d62d731
parentf14a4d4e3f7dd9c0fbb609480912908d4ba2e868 (diff)
downloadFreeBSD-src-112db21947e424c386cd9c5516fde237cc1d61d0.zip
FreeBSD-src-112db21947e424c386cd9c5516fde237cc1d61d0.tar.gz
Keep fork from over extending the number of processes. Since u_map is
sized exactly for maxproc, the occasional overrunning the maxproc limit can cause problems.
-rw-r--r--sys/kern/kern_fork.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index dbb56c4..743128c 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_fork.c 8.6 (Berkeley) 4/8/94
- * $Id: kern_fork.c,v 1.16 1996/01/03 21:42:02 wollman Exp $
+ * $Id: kern_fork.c,v 1.17 1996/02/23 18:49:17 peter Exp $
*/
#include "opt_ktrace.h"
@@ -149,12 +149,22 @@ fork1(p1, forktype, rforkflags, retval)
return (EAGAIN);
}
/*
+ * Increment the nprocs resource before blocking can occur. There
+ * are hard-limits as to the number of processes that can run.
+ */
+ nprocs++;
+
+ /*
* Increment the count of procs running with this uid. Don't allow
* a nonprivileged user to exceed their current limit.
*/
count = chgproccnt(uid, 1);
if (uid != 0 && count > p1->p_rlimit[RLIMIT_NPROC].rlim_cur) {
(void)chgproccnt(uid, -1);
+ /*
+ * Back out the process count
+ */
+ nprocs--;
return (EAGAIN);
}
@@ -214,7 +224,6 @@ again:
* rearranging code. Yes, it *is* terribly ugly, but at least
* it works.
*/
- nprocs++;
p2 = newproc;
#define Vp2 ((volatile struct proc *)p2)
Vp2->p_stat = SIDL; /* protect against others */
OpenPOWER on IntegriCloud