20728: add RLIMIT_SIGPENDING and RLIMIT_MSGQUEUE,

also use ulimit -x for RLIMIT_LOCK
This commit is contained in:
Peter Stephenson 2005-01-19 13:03:33 +00:00
parent 10199323ef
commit f8d74c1aab
5 changed files with 93 additions and 46 deletions

View file

@ -1,3 +1,10 @@
2005-01-19 Peter Stephenson <pws@csr.com>
* 20728 (with typo fixed): configure.ac, Doc/Zsh/builtins.yo,
Src/Builtins/rlimits.awk, Src/Builtins/rlimits.c: Handle
RLIMIT_MSGQUEUE (-q), RLIMIT_SIGPENDING (-i), also use
-x for RLIMIT_LOCKS in ulimit.
2005-01-17 Peter Stephenson <pws@csr.com>
* unposted: suggested by Bart: Etc/FAQ.yo: update a few entries.

View file

@ -679,7 +679,9 @@ sitem(tt(maxproc))(Maximum number of processes.)
sitem(tt(maxpthreads))(Maximum number of threads per process.)
sitem(tt(memorylocked))(Maximum amount of memory locked in RAM.)
sitem(tt(memoryuse))(Maximum resident set size.)
sitem(tt(msgqueue))(Maximum number of bytes in POSIX message queues.)
sitem(tt(resident))(Maximum resident set size.)
sitem(tt(sigpending))(Maximum number of pending signals.)
sitem(tt(sockbufsize))(Maximum size of all socket buffers.)
sitem(tt(stacksize))(Maximum stack size for each process.)
sitem(tt(vmemorysize))(Maximum amount of virtual memory.)
@ -1441,7 +1443,7 @@ enditem()
findex(ulimit)
cindex(resource limits)
cindex(limits, resource)
item(tt(ulimit) [ [ tt(-SHacdflmnpstv) | tt(-N) var(resource) [ var(limit) ] ... ])(
item(tt(ulimit) [ [ tt(-SHacdfilmnpqstvx) | tt(-N) var(resource) [ var(limit) ] ... ])(
Set or display resource limits of the shell and the processes started by
the shell. The value of var(limit) can be a number in the unit specified
below or the value `tt(unlimited)'. By default, only soft limits are
@ -1462,14 +1464,17 @@ sitem(tt(-a))(Lists all of the current resource limits.)
sitem(tt(-c))(512-byte blocks on the size of core dumps.)
sitem(tt(-d))(K-bytes on the size of the data segment.)
sitem(tt(-f))(512-byte blocks on the size of files written.)
sitem(tt(-i))(The number of pending signals.)
sitem(tt(-l))(K-bytes on the size of locked-in memory.)
sitem(tt(-m))(K-bytes on the size of physical memory.)
sitem(tt(-n))(open file descriptors.)
sitem(tt(-q))(Bytes in POSIX message queues.)
sitem(tt(-s))(K-bytes on the size of the stack.)
sitem(tt(-t))(CPU seconds to be used.)
sitem(tt(-u))(processes available to the user.)
sitem(tt(-v))(K-bytes on the size of virtual memory. On some systems this
refers to the limit called `address space'.)
sitem(tt(-x))(The number of locks on files.)
endsitem()
A resource may also be specified by integer in the form `tt(-N)

View file

@ -45,6 +45,8 @@ BEGIN {limidx = 0}
if (limnam == "STACK") { msg[limnum] = "Mstacksize" }
if (limnam == "TCACHE") { msg[limnum] = "Ncachedthreads" }
if (limnam == "VMEM") { msg[limnum] = "Mvmemorysize" }
if (limnam == "SIGPENDING") { msg[limnum] = "Nsigpending" }
if (limnam == "MSGQUEUE") { msg[limnum] = "Nmsgqueue" }
}
}
}

View file

@ -208,13 +208,9 @@ printulimit(char *nam, int lim, int hard, int head)
limit = (hard) ? limits[lim].rlim_max : limits[lim].rlim_cur;
/* display the appropriate heading */
switch (lim) {
case RLIMIT_CPU:
case RLIMIT_CORE:
if (head)
printf("-t: cpu time (seconds) ");
break;
case RLIMIT_FSIZE:
if (head)
printf("-f: file size (blocks) ");
printf("-c: core file size (blocks) ");
if (limit != RLIM_INFINITY)
limit /= 512;
break;
@ -224,18 +220,26 @@ printulimit(char *nam, int lim, int hard, int head)
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
case RLIMIT_STACK:
case RLIMIT_FSIZE:
if (head)
printf("-s: stack size (kbytes) ");
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
case RLIMIT_CORE:
if (head)
printf("-c: core file size (blocks) ");
printf("-f: file size (blocks) ");
if (limit != RLIM_INFINITY)
limit /= 512;
break;
# ifdef HAVE_RLIMIT_SIGPENDING
case RLIMIT_SIGPENDING:
if (head)
printf("-i: pending signals ");
break;
# endif
# ifdef HAVE_RLIMIT_MEMLOCK
case RLIMIT_MEMLOCK:
if (head)
printf("-l: locked-in-memory size (kb) ");
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
# endif /* HAVE_RLIMIT_MEMLOCK */
/* If RLIMIT_VMEM and RLIMIT_RSS are defined and equal, avoid *
* duplicate case statement. Observed on QNX Neutrino 6.1.0. */
# if defined(HAVE_RLIMIT_RSS) && !defined(RLIMIT_VMEM_IS_RSS)
@ -246,34 +250,46 @@ printulimit(char *nam, int lim, int hard, int head)
limit /= 1024;
break;
# endif /* HAVE_RLIMIT_RSS */
# ifdef HAVE_RLIMIT_MEMLOCK
case RLIMIT_MEMLOCK:
# if defined(HAVE_RLIMIT_VMEM) && defined(HAVE_RLIMIT_RSS) && defined(RLIMIT_VMEM_IS_RSS)
case RLIMIT_VMEM:
if (head)
printf("-l: locked-in-memory size (kb) ");
printf("-m: memory size (kb) ");
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
# endif /* HAVE_RLIMIT_MEMLOCK */
# ifdef HAVE_RLIMIT_NPROC
case RLIMIT_NPROC:
if (head)
printf("-u: processes ");
break;
# endif /* HAVE_RLIMIT_NPROC */
# endif /* HAVE_RLIMIT_VMEM */
# ifdef HAVE_RLIMIT_NOFILE
case RLIMIT_NOFILE:
if (head)
printf("-n: file descriptors ");
break;
# endif /* HAVE_RLIMIT_NOFILE */
# ifdef HAVE_RLIMIT_VMEM
# ifdef HAVE_RLIMIT_MSGQUEUE
case RLIMIT_MSGQUEUE:
if (head)
printf("-q: bytes in POSIX msg queues ");
break;
# endif
case RLIMIT_STACK:
if (head)
printf("-s: stack size (kbytes) ");
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
case RLIMIT_CPU:
if (head)
printf("-t: cpu time (seconds) ");
break;
# ifdef HAVE_RLIMIT_NPROC
case RLIMIT_NPROC:
if (head)
printf("-u: processes ");
break;
# endif /* HAVE_RLIMIT_NPROC */
# if defined(HAVE_RLIMIT_VMEM) && (!defined(HAVE_RLIMIT_RSS) || !defined(RLIMIT_VMEM_IS_RSS))
case RLIMIT_VMEM:
if (head)
# if defined(HAVE_RLIMIT_RSS) && defined(RLIMIT_VMEM_IS_RSS)
printf("-m: memory size (kb) ");
# else
printf("-v: virtual memory size (kb) ");
# endif
if (limit != RLIM_INFINITY)
limit /= 1024;
break;
@ -286,18 +302,12 @@ printulimit(char *nam, int lim, int hard, int head)
limit /= 1024;
break;
# endif /* HAVE_RLIMIT_AS */
# ifdef HAVE_RLIMIT_TCACHE
case RLIMIT_TCACHE:
# ifdef HAVE_RLIMIT_LOCKS
case RLIMIT_LOCKS:
if (head)
printf("-N %2d: cached threads ", RLIMIT_TCACHE);
printf("-x: file locks ");
break;
# endif /* HAVE_RLIMIT_TCACHE */
# ifdef HAVE_RLIMIT_AIO_OPS
case RLIMIT_AIO_OPS:
if (head)
printf("-N %2d: AIO operations ", RLIMIT_AIO_OPS);
break;
# endif /* HAVE_RLIMIT_AIO_OPS */
# endif /* HAVE_RLIMIT_LOCKS */
# ifdef HAVE_RLIMIT_AIO_MEM
case RLIMIT_AIO_MEM:
if (head)
@ -306,6 +316,18 @@ printulimit(char *nam, int lim, int hard, int head)
limit /= 1024;
break;
# endif /* HAVE_RLIMIT_AIO_MEM */
# ifdef HAVE_RLIMIT_AIO_OPS
case RLIMIT_AIO_OPS:
if (head)
printf("-N %2d: AIO operations ", RLIMIT_AIO_OPS);
break;
# endif /* HAVE_RLIMIT_AIO_OPS */
# ifdef HAVE_RLIMIT_TCACHE
case RLIMIT_TCACHE:
if (head)
printf("-N %2d: cached threads ", RLIMIT_TCACHE);
break;
# endif /* HAVE_RLIMIT_TCACHE */
# ifdef HAVE_RLIMIT_SBSIZE
case RLIMIT_SBSIZE:
if (head)
@ -320,12 +342,6 @@ printulimit(char *nam, int lim, int hard, int head)
printf("-N %2d: threads per process ", RLIMIT_PTHREAD);
break;
# endif /* HAVE_RLIMIT_PTHREAD */
# ifdef HAVE_RLIMIT_LOCKS
case RLIMIT_LOCKS:
if (head)
printf("-N %2d: file locks ", RLIMIT_LOCKS);
break;
# endif /* HAVE_RLIMIT_LOCKS */
default:
if (head)
printf("-N %2d: ", lim);
@ -745,6 +761,21 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
# endif
break;
# endif /* HAVE_RLIMIT_VMEM */
# ifdef HAVE_RLIMIT_LOCKS
case 'x':
res = RLIMIT_LOCKS;
break;
# endif
# ifdef HAVE_RLIMIT_SIGPENDING
case 'i':
res = RLIMIT_SIGPENDING;
break;
# endif
# ifdef HAVE_RLIMIT_MSGQUEUE
case 'q':
res = RLIMIT_MSGQUEUE;
break;
# endif
default:
/* unrecognised limit */
zwarnnam(name, "bad option: -%c", NULL, *options);

View file

@ -1392,6 +1392,8 @@ zsh_LIMIT_PRESENT(RLIMIT_RSS)
zsh_LIMIT_PRESENT(RLIMIT_SBSIZE)
zsh_LIMIT_PRESENT(RLIMIT_TCACHE)
zsh_LIMIT_PRESENT(RLIMIT_VMEM)
zsh_LIMIT_PRESENT(RLIMIT_SIGPENDING)
zsh_LIMIT_PRESENT(RLIMIT_MSGQUEUE)
AH_TEMPLATE([RLIMIT_VMEM_IS_RSS],
[Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal.])