diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-03-27 05:35:29 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-03-27 05:35:29 +0000 |
commit | 102ca6e5e6c1fb84ea3094025e94e62d8439924e (patch) | |
tree | 6412e9d4dbf2fcb055c7740bed2cd37860dbfd0e /sys/kern | |
parent | ea04172c2de7166d55587bd419b310ac650215a8 (diff) |
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')
-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; |