mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 11:42:21 +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:
parent
8f24d4dc56
commit
8f9d1bec97
8 changed files with 53 additions and 8 deletions
9
ANNOUNCE
9
ANNOUNCE
|
@ -47,6 +47,15 @@ New features in built-in commands:
|
||||||
builtin
|
builtin
|
||||||
file
|
file
|
||||||
|
|
||||||
|
- Added three options to the ulimit builtin with the same names and
|
||||||
|
functionality as in Bash:
|
||||||
|
- 'ulimit -k' sets the maximum number of kqueues.
|
||||||
|
- 'ulimit -P' sets the maximum number of pseudo-terminals.
|
||||||
|
- 'ulimit -R' sets the maximum time in microseconds a real-time process
|
||||||
|
can run before blocking.
|
||||||
|
Note that to use these options the operating system must support the
|
||||||
|
corresponding resource limit.
|
||||||
|
|
||||||
### MAIN CHANGES between 1.0.0-beta.1 and 1.0.0-beta.2 ###
|
### MAIN CHANGES between 1.0.0-beta.1 and 1.0.0-beta.2 ###
|
||||||
|
|
||||||
New features in built-in commands:
|
New features in built-in commands:
|
||||||
|
|
11
NEWS
11
NEWS
|
@ -3,6 +3,17 @@ For full details, see the git log at: https://github.com/ksh93/ksh
|
||||||
|
|
||||||
Any uppercase BUG_* names are modernish shell bug IDs.
|
Any uppercase BUG_* names are modernish shell bug IDs.
|
||||||
|
|
||||||
|
2021-12-28:
|
||||||
|
|
||||||
|
- Added three options to the ulimit builtin with the same names and
|
||||||
|
functionality as in Bash:
|
||||||
|
- 'ulimit -k' sets the maximum number of kqueues.
|
||||||
|
- 'ulimit -P' sets the maximum number of pseudo-terminals.
|
||||||
|
- 'ulimit -R' sets the maximum time in microseconds a real-time process
|
||||||
|
can run before blocking.
|
||||||
|
Note that to use these options the operating system must support the
|
||||||
|
corresponding resource limit.
|
||||||
|
|
||||||
2021-12-27:
|
2021-12-27:
|
||||||
|
|
||||||
- Two bash-like flags for 'whence' were backported from ksh 93v-:
|
- Two bash-like flags for 'whence' were backported from ksh 93v-:
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
* *
|
* *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
/*
|
/*
|
||||||
* ulimit [-HSaMctdfxlqenupmrbiswTv] [limit]
|
* ulimit [-HSaMctdfkxlqenuPpmrRbiswTv] [limit]
|
||||||
*
|
*
|
||||||
* David Korn
|
* David Korn
|
||||||
* AT&T Labs
|
* AT&T Labs
|
||||||
|
@ -78,7 +78,7 @@ int b_ulimit(int argc,char *argv[],Shbltin_t *context)
|
||||||
char* conf;
|
char* conf;
|
||||||
int label, unit, nosupport;
|
int label, unit, nosupport;
|
||||||
rlim_t i;
|
rlim_t i;
|
||||||
char tmp[32];
|
char tmp[41];
|
||||||
Optdisc_t disc;
|
Optdisc_t disc;
|
||||||
memset(&disc, 0, sizeof(disc));
|
memset(&disc, 0, sizeof(disc));
|
||||||
disc.version = OPT_VERSION;
|
disc.version = OPT_VERSION;
|
||||||
|
@ -218,7 +218,7 @@ int b_ulimit(int argc,char *argv[],Shbltin_t *context)
|
||||||
sfsprintf(tmp,sizeof(tmp),"%s (%ss)", tp->description, e_units[tp->type]);
|
sfsprintf(tmp,sizeof(tmp),"%s (%ss)", tp->description, e_units[tp->type]);
|
||||||
else
|
else
|
||||||
sfsprintf(tmp,sizeof(tmp),"%s", tp->name);
|
sfsprintf(tmp,sizeof(tmp),"%s", tp->name);
|
||||||
sfprintf(sfstdout,"%-30s (-%c) ",tmp,tp->option);
|
sfprintf(sfstdout,"%-39s (-%c) ",tmp,tp->option);
|
||||||
}
|
}
|
||||||
if(nosupport)
|
if(nosupport)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1906,7 +1906,7 @@ const char sh_opttypeset[] =
|
||||||
;
|
;
|
||||||
|
|
||||||
const char sh_optulimit[] =
|
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 "]"
|
"[--catalog?" SH_DICT "]"
|
||||||
"[+NAME?ulimit - set or display resource limits]"
|
"[+NAME?ulimit - set or display resource limits]"
|
||||||
"[+DESCRIPTION?\bulimit\b sets or displays resource limits. These "
|
"[+DESCRIPTION?\bulimit\b sets or displays resource limits. These "
|
||||||
|
|
|
@ -30,9 +30,9 @@
|
||||||
#ifndef _no_ulimit
|
#ifndef _no_ulimit
|
||||||
|
|
||||||
const char e_unlimited[] = "unlimited";
|
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[] =
|
const Limit_t shtab_limits[] =
|
||||||
{
|
{
|
||||||
|
@ -41,15 +41,18 @@ const Limit_t shtab_limits[] =
|
||||||
"cpu", "cpu time", RLIMIT_CPU, 0, 't', LIM_SECOND,
|
"cpu", "cpu time", RLIMIT_CPU, 0, 't', LIM_SECOND,
|
||||||
"data", "data size", RLIMIT_DATA, 0, 'd', LIM_KBYTE,
|
"data", "data size", RLIMIT_DATA, 0, 'd', LIM_KBYTE,
|
||||||
"fsize", "file size", RLIMIT_FSIZE, 0, 'f', LIM_BLOCK,
|
"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,
|
"locks", "number of file locks", RLIMIT_LOCKS, 0, 'x', LIM_COUNT,
|
||||||
"memlock", "locked address space", RLIMIT_MEMLOCK, 0, 'l', LIM_KBYTE,
|
"memlock", "locked address space", RLIMIT_MEMLOCK, 0, 'l', LIM_KBYTE,
|
||||||
"msgqueue", "message queue size", RLIMIT_MSGQUEUE,0, 'q', LIM_KBYTE,
|
"msgqueue", "message queue size", RLIMIT_MSGQUEUE,0, 'q', LIM_KBYTE,
|
||||||
"nice", "scheduling priority", RLIMIT_NICE, 0, 'e', LIM_COUNT,
|
"nice", "scheduling priority", RLIMIT_NICE, 0, 'e', LIM_COUNT,
|
||||||
"nofile", "number of open files", RLIMIT_NOFILE, "OPEN_MAX", 'n', 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,
|
"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,
|
"pipe", "pipe buffer size", RLIMIT_PIPE, "PIPE_BUF", 'p', LIM_BYTE,
|
||||||
"rss", "max memory size", RLIMIT_RSS, 0, 'm', LIM_KBYTE,
|
"rss", "max memory size", RLIMIT_RSS, 0, 'm', LIM_KBYTE,
|
||||||
"rtprio", "max real-time priority",RLIMIT_RTPRIO, 0, 'r', LIM_COUNT,
|
"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,
|
"sbsize", "socket buffer size", RLIMIT_SBSIZE, "PIPE_BUF", 'b', LIM_BYTE,
|
||||||
"sigpend", "signal queue size", RLIMIT_SIGPENDING,"SIGQUEUE_MAX",'i', LIM_COUNT,
|
"sigpend", "signal queue size", RLIMIT_SIGPENDING,"SIGQUEUE_MAX",'i', LIM_COUNT,
|
||||||
"stack", "stack size", RLIMIT_STACK, 0, 's', LIM_KBYTE,
|
"stack", "stack size", RLIMIT_STACK, 0, 's', LIM_KBYTE,
|
||||||
|
|
|
@ -103,6 +103,9 @@
|
||||||
#ifndef RLIMIT_FSIZE
|
#ifndef RLIMIT_FSIZE
|
||||||
#define RLIMIT_FSIZE RLIMIT_UNKNOWN
|
#define RLIMIT_FSIZE RLIMIT_UNKNOWN
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef RLIMIT_KQUEUES
|
||||||
|
#define RLIMIT_KQUEUES RLIMIT_UNKNOWN
|
||||||
|
#endif
|
||||||
#ifndef RLIMIT_LOCKS
|
#ifndef RLIMIT_LOCKS
|
||||||
#define RLIMIT_LOCKS RLIMIT_UNKNOWN
|
#define RLIMIT_LOCKS RLIMIT_UNKNOWN
|
||||||
#endif
|
#endif
|
||||||
|
@ -121,6 +124,9 @@
|
||||||
#ifndef RLIMIT_NPROC
|
#ifndef RLIMIT_NPROC
|
||||||
#define RLIMIT_NPROC RLIMIT_UNKNOWN
|
#define RLIMIT_NPROC RLIMIT_UNKNOWN
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef RLIMIT_NPTS
|
||||||
|
#define RLIMIT_NPTS RLIMIT_UNKNOWN
|
||||||
|
#endif
|
||||||
#ifndef RLIMIT_PIPE
|
#ifndef RLIMIT_PIPE
|
||||||
#define RLIMIT_PIPE RLIMIT_UNKNOWN
|
#define RLIMIT_PIPE RLIMIT_UNKNOWN
|
||||||
#endif
|
#endif
|
||||||
|
@ -133,6 +139,9 @@
|
||||||
#ifndef RLIMIT_RTPRIO
|
#ifndef RLIMIT_RTPRIO
|
||||||
#define RLIMIT_RTPRIO RLIMIT_UNKNOWN
|
#define RLIMIT_RTPRIO RLIMIT_UNKNOWN
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef RLIMIT_RTTIME
|
||||||
|
#define RLIMIT_RTTIME RLIMIT_UNKNOWN
|
||||||
|
#endif
|
||||||
#ifndef RLIMIT_SBSIZE
|
#ifndef RLIMIT_SBSIZE
|
||||||
#define RLIMIT_SBSIZE RLIMIT_UNKNOWN
|
#define RLIMIT_SBSIZE RLIMIT_UNKNOWN
|
||||||
#endif
|
#endif
|
||||||
|
@ -154,6 +163,7 @@
|
||||||
#define LIM_BYTE 2
|
#define LIM_BYTE 2
|
||||||
#define LIM_KBYTE 3
|
#define LIM_KBYTE 3
|
||||||
#define LIM_SECOND 4
|
#define LIM_SECOND 4
|
||||||
|
#define LIM_MICROSECOND 5
|
||||||
|
|
||||||
typedef struct Limit_s
|
typedef struct Limit_s
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
||||||
#define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
|
#define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
|
||||||
#define SH_RELEASE_DATE "2021-12-27" /* must be in this format for $((.sh.version)) */
|
#define SH_RELEASE_DATE "2021-12-28" /* must be in this format for $((.sh.version)) */
|
||||||
#define SH_RELEASE_CPYR "(c) 2020-2021 Contributors to ksh " SH_RELEASE_FORK
|
#define SH_RELEASE_CPYR "(c) 2020-2021 Contributors to ksh " SH_RELEASE_FORK
|
||||||
|
|
||||||
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
||||||
|
|
|
@ -8079,7 +8079,7 @@ that have attributes
|
||||||
are printed.
|
are printed.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
\f3ulimit\fP \*(OK \f3\-HSaMctdfxlqenupmrbiswTv\fP \*(CK \*(OK \f2limit\^\fP \*(CK
|
\f3ulimit\fP \*(OK \f3\-HSaMctdfkxlqenuPpmrRbiswTv\fP \*(CK \*(OK \f2limit\^\fP \*(CK
|
||||||
Set or display a resource limit.
|
Set or display a resource limit.
|
||||||
The available resource limits are listed below.
|
The available resource limits are listed below.
|
||||||
Many systems do not support one or more of these limits.
|
Many systems do not support one or more of these limits.
|
||||||
|
@ -8137,6 +8137,9 @@ current process or by child processes (files of any size may be read).
|
||||||
.B \-i
|
.B \-i
|
||||||
The signal queue size.
|
The signal queue size.
|
||||||
.TP
|
.TP
|
||||||
|
.B \-k
|
||||||
|
The max number of kqueues created by the current user.
|
||||||
|
.TP
|
||||||
.B \-l
|
.B \-l
|
||||||
The locked address space in K-bytes.
|
The locked address space in K-bytes.
|
||||||
.TP
|
.TP
|
||||||
|
@ -8149,12 +8152,21 @@ The number of K-bytes on the size of physical memory.
|
||||||
.B \-n
|
.B \-n
|
||||||
The number of file descriptors plus 1.
|
The number of file descriptors plus 1.
|
||||||
.TP
|
.TP
|
||||||
|
.B \-P
|
||||||
|
The max number of pseudo-terminals created by the current user.
|
||||||
|
.TP
|
||||||
.B \-p
|
.B \-p
|
||||||
The number of 512-byte blocks for pipe buffering.
|
The number of 512-byte blocks for pipe buffering.
|
||||||
.TP
|
.TP
|
||||||
.B \-q
|
.B \-q
|
||||||
The message queue size in K-bytes.
|
The message queue size in K-bytes.
|
||||||
.TP
|
.TP
|
||||||
|
.B \-R
|
||||||
|
The max time a real-time process can run before blocking, in microseconds. If this limit is exceeded
|
||||||
|
the process is sent a
|
||||||
|
.B SIGXCPU
|
||||||
|
signal.
|
||||||
|
.TP
|
||||||
.B \-r
|
.B \-r
|
||||||
The max real-time priority.
|
The max real-time priority.
|
||||||
.TP
|
.TP
|
||||||
|
|
Loading…
Reference in a new issue