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 | |
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')
-rw-r--r-- | sys/kern/init_main.c | 9 | ||||
-rw-r--r-- | sys/sys/param.h | 5 |
2 files changed, 11 insertions, 3 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; diff --git a/sys/sys/param.h b/sys/sys/param.h index 4cb4f8bc2ac..cd1490f63e8 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -1,4 +1,4 @@ -/* $OpenBSD: param.h,v 1.11 1996/10/25 11:14:45 deraadt Exp $ */ +/* $OpenBSD: param.h,v 1.12 1997/03/27 05:35:25 millert Exp $ */ /* $NetBSD: param.h,v 1.23 1996/03/17 01:02:29 thorpej Exp $ */ /*- @@ -71,7 +71,8 @@ #define MAXUPRC CHILD_MAX /* max simultaneous processes */ #define NCARGS ARG_MAX /* max bytes for an exec function */ #define NGROUPS NGROUPS_MAX /* max number groups */ -#define NOFILE OPEN_MAX /* max open files per process */ +#define NOFILE OPEN_MAX /* max open files per process (soft) */ +#define NOFILE_MAX 1024 /* max open files per process (hard) */ #define NOGROUP 65535 /* marker for empty group set member */ #define MAXHOSTNAMELEN 256 /* max hostname size */ |