Make limits(1) aware of the new vmemoryuse resource limit.

Submitted by:	sheldonh
This commit is contained in:
dillon 2002-06-26 03:43:25 +00:00
parent 0bcacbc119
commit 51cf7f973f
2 changed files with 37 additions and 16 deletions

View File

@ -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
@ -229,6 +229,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.
.El
.Pp
Valid values for

View File

@ -84,7 +84,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", "",
@ -98,7 +99,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,
@ -112,7 +114,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", "",
@ -126,7 +129,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,
@ -140,7 +144,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", "",
@ -154,7 +159,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", "",
@ -168,7 +174,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,
@ -182,7 +189,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, NULL, NULL, NULL, NULL, NULL,
@ -203,7 +211,8 @@ static struct {
{ "memorylocked", login_getcapsize },
{ "maxproc", login_getcapnum },
{ "openfiles", login_getcapnum },
{ "sbsize", login_getcapsize }
{ "sbsize", login_getcapsize },
{ "vmemoryuse", login_getcapsize }
};
/*
@ -214,7 +223,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);
@ -250,7 +259,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;
@ -459,7 +468,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);
}
@ -529,6 +538,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) {