diff --git a/usr.bin/limits/limits.1 b/usr.bin/limits/limits.1 --- a/usr.bin/limits/limits.1 +++ b/usr.bin/limits/limits.1 @@ -17,7 +17,7 @@ .\" 5. Modifications may be freely made to this file providing the above .\" conditions are met. .\" -.Dd June 25, 2020 +.Dd December 17, 2025 .Dt LIMITS 1 .Os .Sh NAME @@ -28,11 +28,11 @@ .Op Fl C Ar class | Fl P Ar pid | Fl U Ar user .Op Fl SHB .Op Fl ea -.Op Fl bcdfklmnopstuvw Op Ar val +.Op Fl bcdfklmnopstuVvwy Op Ar val .Nm .Op Fl C Ar class | Fl U Ar user .Op Fl SHB -.Op Fl bcdfklmnopstuvwy Op Ar val +.Op Fl bcdfklmnopstuVvwy Op Ar val .Op Fl E .Oo .Op Ar name Ns = Ns Ar value ... @@ -265,6 +265,10 @@ .Va kern.maxproc .Xr sysctl 8 variable. +.It Fl V Op Ar val +Select or set the +.Va vmms +resource limit. .It Fl v Op Ar val Select or set the .Va virtualmem diff --git a/usr.bin/limits/limits.c b/usr.bin/limits/limits.c --- a/usr.bin/limits/limits.c +++ b/usr.bin/limits/limits.c @@ -228,7 +228,7 @@ static struct { const char * cap; rlim_t (*func)(login_cap_t *, const char *, rlim_t, rlim_t); -} resources[RLIM_NLIMITS] = { +} resources[] = { { "cputime", login_getcaptime }, { "filesize", login_getcapsize }, { "datasize", login_getcapsize }, @@ -245,8 +245,12 @@ { "kqueues", login_getcapnum }, { "umtxp", login_getcapnum }, { "pipebuf", login_getcapnum }, + { "vmms", login_getcapnum }, }; +_Static_assert(nitems(resources) == RLIM_NLIMITS, + "Please add entries to resources[] for the new limits"); + /* * One letter for each resource levels. * NOTE: There is a dependency on the corresponding @@ -254,8 +258,9 @@ * If sys/resource.h defines are changed, this needs * to be modified accordingly! */ - -#define RCS_STRING "tfdscmlunbvpwkoy" +static const char rcs_string[] = "tfdscmlunbvpwkoyV"; +_Static_assert(sizeof(rcs_string) - 1 == RLIM_NLIMITS, + "Please add letters to rcs_string[] for the new limits"); static rlim_t resource_num(int which, int ch, const char *str); static void usage(void) __dead2; @@ -266,8 +271,6 @@ static void setrlimit_proc(pid_t pid, int resource, const struct rlimit *rlp); extern char **environ; -static const char rcs_string[] = RCS_STRING; - int main(int argc, char *argv[]) { @@ -295,7 +298,7 @@ pid = -1; optarg = NULL; while ((ch = getopt(argc, argv, - ":EeC:U:BSHP:ab:c:d:f:l:m:n:s:t:u:v:p:w:k:o:y:")) != -1) { + ":EeC:U:BSHP:ab:c:d:f:l:m:n:s:t:u:V:v:p:w:k:o:y:")) != -1) { switch(ch) { case 'a': doall = 1; @@ -552,7 +555,7 @@ { (void)fprintf(stderr, "usage: limits [-C class|-P pid|-U user] [-eaSHBE] " - "[-bcdfklmnostuvpw [val]] [[name=val ...] cmd]\n"); + "[-bcdfklmnostuVvpwy [val]] [[name=val ...] cmd]\n"); exit(EXIT_FAILURE); } @@ -664,6 +667,7 @@ case RLIMIT_NPTS: case RLIMIT_KQUEUES: case RLIMIT_UMTXP: + case RLIMIT_VMM: res = strtoq(s, &e, 0); s = e; break;