diff options
author | 1997-03-27 05:35:25 +0000 | |
---|---|---|
committer | 1997-03-27 05:35:25 +0000 | |
commit | aa66f5ec26edcacab151685c6c4b373569c33a0e (patch) | |
tree | 5778ba6e9473a61ee533948a34ba74c6ebcf3ee1 /sys/kern/init_main.c | |
parent | Make kern.osrevision (sysctl) and /kern/osrev report value of (diff) | |
download | wireguard-openbsd-aa66f5ec26edcacab151685c6c4b373569c33a0e.tar.xz wireguard-openbsd-aa66f5ec26edcacab151685c6c4b373569c33a0e.zip |
Implement NOFILE_MAX--hard limit on max descriptors per proccess.
Future direction, might make sense to make this a kernel symbol tha
is sysctl-able.
Diffstat (limited to 'sys/kern/init_main.c')
-rw-r--r-- | sys/kern/init_main.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 496426a6070..eb4e1712fe1 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.20 1996/11/06 01:29:46 deraadt Exp $ */ +/* $OpenBSD: init_main.c,v 1.21 1997/03/27 05:35:28 millert Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -44,6 +44,7 @@ #include <sys/param.h> #include <sys/filedesc.h> +#include <sys/file.h> #include <sys/errno.h> #include <sys/exec.h> #include <sys/kernel.h> @@ -94,6 +95,10 @@ extern void nfs_init __P((void)); #endif +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + char copyright[] = "Copyright (c) 1982, 1986, 1989, 1991, 1993\n\tThe Regents of the University of California. All rights reserved.\n\n"; @@ -239,6 +244,8 @@ main(framep) limit0.pl_rlimit[i].rlim_cur = limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY; limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur = NOFILE; + limit0.pl_rlimit[RLIMIT_NOFILE].rlim_max = MIN(NOFILE_MAX, + (maxfiles - NOFILE > NOFILE) ? maxfiles - NOFILE : NOFILE); limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur = MAXUPRC; i = ptoa(cnt.v_free_count); limit0.pl_rlimit[RLIMIT_RSS].rlim_max = i; |