From e9b23502de0a0314b703dca31d9689ebab5c8dbf Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 2 Jul 2002 20:06:25 +0000 Subject: MFC RLIMIT_VMEM resource Stage I - limit the total virtual memory use for a process (exec() to be handled in Stage II). --- usr.bin/limits/limits.1 | 19 +++++++++++++++---- usr.bin/limits/limits.c | 34 ++++++++++++++++++++++------------ 2 files changed, 37 insertions(+), 16 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/limits/limits.1 b/usr.bin/limits/limits.1 index 59cc90adc7d8..d24d081ff137 100644 --- a/usr.bin/limits/limits.1 +++ b/usr.bin/limits/limits.1 @@ -30,11 +30,11 @@ .Op Fl C Ar class .Op Fl SHB .Op Fl ea -.Op Fl cdflmnstu Op val +.Op Fl cdflmnstuv Op val .Nm .Op Fl C Ar class .Op Fl SHB -.Op Fl cdflmnstu Op val +.Op Fl cdflmnstuv Op val .Op Fl E .Op Ar name Ns = Ns Ar value ... .Op Ar command @@ -42,11 +42,11 @@ .Op Fl U Ar user .Op Fl SHB .Op Fl ea -.Op Fl cdflmnstu Op val +.Op Fl cdflmnstuv Op val .Nm .Op Fl U Ar user .Op Fl SHB -.Op Fl cdflmnstu Op val +.Op Fl cdflmnstuv Op val .Op Fl E .Op Ar name Ns = Ns Ar value ... .Op Ar command @@ -228,6 +228,17 @@ allowed per UID can be viewed using the 'sysctl kern.maxprocperuid' command. The maximum number of processes that can be running simultaneously in the entire system is limited to the value given by the 'sysctl kern.maxproc' command. +.It Fl v Op Ar limit +Select or set the +.Em virtualmem +resource limit. +This limit encompasses the entire VM space for the user process +and is inclusive of text, data, bss, stack, +.Xr brk 2 , +.Xr sbrk 2 +and +.Xr mmap 2 Ns 'd +space. .Pp Valid values for .Ar limit diff --git a/usr.bin/limits/limits.c b/usr.bin/limits/limits.c index 1fe07b3bb915..38ced816759c 100644 --- a/usr.bin/limits/limits.c +++ b/usr.bin/limits/limits.c @@ -83,7 +83,8 @@ static struct { { " memorylocked%-4s %8s", " kb\n", 1024 }, { " maxprocesses%-4s %8s", "\n", 1 }, { " openfiles%-4s %8s", "\n", 1 }, - { " sbsize%-4s %8s", " bytes\n", 1 } + { " sbsize%-4s %8s", " bytes\n", 1 }, + { " vmemoryuse%-4s %8s", " kb\n", 1024 } } }, { "sh", "unlimited", "", " -H", " -S", "", @@ -97,7 +98,8 @@ static struct { { "ulimit%s -l %s", ";\n", 1024 }, { "ulimit%s -u %s", ";\n", 1 }, { "ulimit%s -n %s", ";\n", 1 }, - { "ulimit%s -b %s", ";\n", 1 } + { "ulimit%s -b %s", ";\n", 1 }, + { "ulimit%s -v %s", ";\n", 1024 } } }, { "csh", "unlimited", "", " -h", "", NULL, @@ -111,7 +113,8 @@ static struct { { "limit%s memorylocked %s", ";\n", 1024 }, { "limit%s maxproc %s", ";\n", 1 }, { "limit%s openfiles %s", ";\n", 1 }, - { "limit%s sbsize %s", ";\n", 1 } + { "limit%s sbsize %s", ";\n", 1 }, + { "limit%s vmemoryuse %s", ";\n", 1024 } } }, { "bash|bash2", "unlimited", "", " -H", " -S", "", @@ -125,7 +128,8 @@ static struct { { "ulimit%s -l %s", ";\n", 1024 }, { "ulimit%s -u %s", ";\n", 1 }, { "ulimit%s -n %s", ";\n", 1 }, - { "ulimit%s -b %s", ";\n", 1 } + { "ulimit%s -b %s", ";\n", 1 }, + { "ulimit%s -v %s", ";\n", 1024 } } }, { "tcsh", "unlimited", "", " -h", "", NULL, @@ -139,7 +143,8 @@ static struct { { "limit%s memorylocked %s", ";\n", 1024 }, { "limit%s maxproc %s", ";\n", 1 }, { "limit%s descriptors %s", ";\n", 1 }, - { "limit%s sbsize %s", ";\n", 1 } + { "limit%s sbsize %s", ";\n", 1 }, + { "limit%s vmemoryuse %s", ";\n", 1024 } } }, { "ksh|pdksh", "unlimited", "", " -H", " -S", "", @@ -153,7 +158,8 @@ static struct { { "ulimit%s -l %s", ";\n", 1024 }, { "ulimit%s -p %s", ";\n", 1 }, { "ulimit%s -n %s", ";\n", 1 }, - { "ulimit%s -b %s", ";\n", 1 } + { "ulimit%s -b %s", ";\n", 1 }, + { "ulimit%s -v %s", ";\n", 1024 } } }, { "zsh", "unlimited", "", " -H", " -S", "", @@ -167,7 +173,8 @@ static struct { { "ulimit%s -l %s", ";\n", 1024 }, { "ulimit%s -u %s", ";\n", 1 }, { "ulimit%s -n %s", ";\n", 1 }, - { "ulimit%s -b %s", ";\n", 1 } + { "ulimit%s -b %s", ";\n", 1 }, + { "ulimit%s -v %s", ";\n", 1024 } } }, { "rc|es", "unlimited", "", " -h", "", NULL, @@ -181,7 +188,8 @@ static struct { { "limit%s lockedmemory %s", ";\n", 1024 }, { "limit%s processes %s", ";\n", 1 }, { "limit%s descriptors %s", ";\n", 1 }, - { "limit%s sbsize %s", ";\n", 1 } + { "limit%s sbsize %s", ";\n", 1 }, + { "limit%s vmemoryuse %s", ";\n", 1024 } } }, { NULL } @@ -200,7 +208,8 @@ static struct { { "memorylocked", login_getcapsize }, { "maxproc", login_getcapnum }, { "openfiles", login_getcapnum }, - { "sbsize", login_getcapnum } + { "sbsize", login_getcapnum }, + { "vmemoryuse", login_getcapsize } }; /* @@ -211,7 +220,7 @@ static struct { * to be modified accordingly! */ -#define RCS_STRING "tfdscmlunb" +#define RCS_STRING "tfdscmlunbv" static rlim_t resource_num(int which, int ch, const char *str); static void usage(void); @@ -247,7 +256,7 @@ main(int argc, char *argv[]) } optarg = NULL; - while ((ch = getopt(argc, argv, ":EeC:U:BSHabc:d:f:l:m:n:s:t:u:")) != -1) { + while ((ch = getopt(argc, argv, ":EeC:U:BSHabc:d:f:l:m:n:s:t:u:v:")) != -1) { switch(ch) { case 'a': doall = 1; @@ -456,7 +465,7 @@ static void usage(void) { (void)fprintf(stderr, -"usage: limits [-C class|-U user] [-eaSHBE] [-bcdflmnstu [val]] [[name=val ...] cmd]\n"); +"usage: limits [-C class|-U user] [-eaSHBE] [-bcdflmnstuv [val]] [[name=val ...] cmd]\n"); exit(EXIT_FAILURE); } @@ -526,6 +535,7 @@ resource_num(int which, int ch, const char *str) case RLIMIT_CORE: case RLIMIT_RSS: case RLIMIT_MEMLOCK: + case RLIMIT_VMEM: errno = 0; res = 0; while (*s) { -- cgit v1.3