1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Add three options to 'ulimit' (#406)

This patch adds a few extra options to the ulimit command (if the OS
supports them). These options are also present in Bash, although in ksh
additional long forms of each option are available:
  ulimit -k/--kqueues   This is the maximum number of kqueues.
  ulimit -P/--npts      This is the maximum number of pseudo-terminals.
  ulimit -R/--rttime    This is the time a real-time process can run
                        before blocking, in microseconds. When the
                        limit is exceeded, the process is sent SIGXCPU.

Other changes:
- bltins/ulimit.c: Change the formatting from sfprintf and increase the
  size of the tmp buffer to prevent text from being cut off in ulimit
  -a (this was required to add ulimit -R).
- data/limits.c: Add support for using microseconds as a unit.
This commit is contained in:
Johnothan King 2021-12-28 13:55:56 -08:00 committed by Martijn Dekker
parent 8f24d4dc56
commit 8f9d1bec97
8 changed files with 53 additions and 8 deletions

View file

@ -1906,7 +1906,7 @@ const char sh_opttypeset[] =
;
const char sh_optulimit[] =
"[-1c?@(#)$Id: ulimit (AT&T Research) 2003-06-21 $\n]"
"[-1c?@(#)$Id: ulimit (ksh 93u+m) 2021-12-28 $\n]"
"[--catalog?" SH_DICT "]"
"[+NAME?ulimit - set or display resource limits]"
"[+DESCRIPTION?\bulimit\b sets or displays resource limits. These "

View file

@ -30,9 +30,9 @@
#ifndef _no_ulimit
const char e_unlimited[] = "unlimited";
const char* e_units[] = { 0, "block", "byte", "Kibyte", "second" };
const char* e_units[] = { 0, "block", "byte", "Kibyte", "second", "microsecond" };
const int shtab_units[] = { 1, 512, 1, 1024, 1 };
const int shtab_units[] = { 1, 512, 1, 1024, 1, 1 };
const Limit_t shtab_limits[] =
{
@ -41,15 +41,18 @@ const Limit_t shtab_limits[] =
"cpu", "cpu time", RLIMIT_CPU, 0, 't', LIM_SECOND,
"data", "data size", RLIMIT_DATA, 0, 'd', LIM_KBYTE,
"fsize", "file size", RLIMIT_FSIZE, 0, 'f', LIM_BLOCK,
"kqueues", "number of kqueues", RLIMIT_KQUEUES, 0, 'k', LIM_COUNT,
"locks", "number of file locks", RLIMIT_LOCKS, 0, 'x', LIM_COUNT,
"memlock", "locked address space", RLIMIT_MEMLOCK, 0, 'l', LIM_KBYTE,
"msgqueue", "message queue size", RLIMIT_MSGQUEUE,0, 'q', LIM_KBYTE,
"nice", "scheduling priority", RLIMIT_NICE, 0, 'e', LIM_COUNT,
"nofile", "number of open files", RLIMIT_NOFILE, "OPEN_MAX", 'n', LIM_COUNT,
"nproc", "number of processes", RLIMIT_NPROC, "CHILD_MAX", 'u', LIM_COUNT,
"npts", "number of pseudo-terminals", RLIMIT_NPTS, 0, 'P', LIM_COUNT,
"pipe", "pipe buffer size", RLIMIT_PIPE, "PIPE_BUF", 'p', LIM_BYTE,
"rss", "max memory size", RLIMIT_RSS, 0, 'm', LIM_KBYTE,
"rtprio", "max real-time priority",RLIMIT_RTPRIO, 0, 'r', LIM_COUNT,
"rttime", "max time before blocking", RLIMIT_RTTIME, 0, 'R', LIM_MICROSECOND,
"sbsize", "socket buffer size", RLIMIT_SBSIZE, "PIPE_BUF", 'b', LIM_BYTE,
"sigpend", "signal queue size", RLIMIT_SIGPENDING,"SIGQUEUE_MAX",'i', LIM_COUNT,
"stack", "stack size", RLIMIT_STACK, 0, 's', LIM_KBYTE,