ash,hush: bash compat for ulimit: -w => -x, -p => -u

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2019-04-27 21:23:39 +02:00
parent a4d76ea137
commit a92a9601f8

View File

@ -354,22 +354,22 @@ static const struct limits limits_tbl[] = {
{ RLIMIT_CORE, 9, "core file size (blocks)" }, // -c { RLIMIT_CORE, 9, "core file size (blocks)" }, // -c
#endif #endif
#ifdef RLIMIT_RSS #ifdef RLIMIT_RSS
{ RLIMIT_RSS, 10, "resident set size (kb)" }, // -m { RLIMIT_RSS, 10, "max memory size (kb)" }, // -m
#endif #endif
#ifdef RLIMIT_MEMLOCK #ifdef RLIMIT_MEMLOCK
{ RLIMIT_MEMLOCK, 10, "locked memory (kb)" }, // -l { RLIMIT_MEMLOCK, 10, "max locked memory (kb)" }, // -l
#endif #endif
#ifdef RLIMIT_NPROC #ifdef RLIMIT_NPROC
{ RLIMIT_NPROC, 0, "processes" }, // -p { RLIMIT_NPROC, 0, "max user processes" }, // -u
#endif #endif
#ifdef RLIMIT_NOFILE #ifdef RLIMIT_NOFILE
{ RLIMIT_NOFILE, 0, "file descriptors" }, // -n { RLIMIT_NOFILE, 0, "open files" }, // -n
#endif #endif
#ifdef RLIMIT_AS #ifdef RLIMIT_AS
{ RLIMIT_AS, 10, "address space (kb)" }, // -v { RLIMIT_AS, 10, "virtual memory (kb)" }, // -v
#endif #endif
#ifdef RLIMIT_LOCKS #ifdef RLIMIT_LOCKS
{ RLIMIT_LOCKS, 0, "locks" }, // -w { RLIMIT_LOCKS, 0, "file locks" }, // -x
#endif #endif
#ifdef RLIMIT_NICE #ifdef RLIMIT_NICE
{ RLIMIT_NICE, 0, "scheduling priority" }, // -e { RLIMIT_NICE, 0, "scheduling priority" }, // -e
@ -378,6 +378,10 @@ static const struct limits limits_tbl[] = {
{ RLIMIT_RTPRIO, 0, "real-time priority" }, // -r { RLIMIT_RTPRIO, 0, "real-time priority" }, // -r
#endif #endif
}; };
// bash also has these:
//pending signals (-i) 61858 //RLIMIT_SIGPENDING
//pipe size (512 bytes, -p) 8
//POSIX message queues (bytes, -q) 819200 //RLIMIT_MSGQUEUE
static const char limit_chars[] ALIGN1 = static const char limit_chars[] ALIGN1 =
"f" "f"
@ -400,7 +404,7 @@ static const char limit_chars[] ALIGN1 =
"l" "l"
#endif #endif
#ifdef RLIMIT_NPROC #ifdef RLIMIT_NPROC
"p" "u"
#endif #endif
#ifdef RLIMIT_NOFILE #ifdef RLIMIT_NOFILE
"n" "n"
@ -409,7 +413,7 @@ static const char limit_chars[] ALIGN1 =
"v" "v"
#endif #endif
#ifdef RLIMIT_LOCKS #ifdef RLIMIT_LOCKS
"w" "x"
#endif #endif
#ifdef RLIMIT_NICE #ifdef RLIMIT_NICE
"e" "e"
@ -441,7 +445,7 @@ static const char ulimit_opt_string[] ALIGN1 = "-HSa"
"l::" "l::"
#endif #endif
#ifdef RLIMIT_NPROC #ifdef RLIMIT_NPROC
"p::" "u::"
#endif #endif
#ifdef RLIMIT_NOFILE #ifdef RLIMIT_NOFILE
"n::" "n::"
@ -450,7 +454,7 @@ static const char ulimit_opt_string[] ALIGN1 = "-HSa"
"v::" "v::"
#endif #endif
#ifdef RLIMIT_LOCKS #ifdef RLIMIT_LOCKS
"w::" "x::"
#endif #endif
#ifdef RLIMIT_NICE #ifdef RLIMIT_NICE
"e::" "e::"
@ -571,7 +575,7 @@ shell_builtin_ulimit(char **argv)
if (opts & OPT_all) { if (opts & OPT_all) {
for (i = 0; i < ARRAY_SIZE(limits_tbl); i++) { for (i = 0; i < ARRAY_SIZE(limits_tbl); i++) {
getrlimit(limits_tbl[i].cmd, &limit); getrlimit(limits_tbl[i].cmd, &limit);
printf("-%c: %-30s ", limit_chars[i], limits_tbl[i].name); printf("%-32s(-%c) ", limits_tbl[i].name, limit_chars[i]);
printlim(opts, &limit, &limits_tbl[i]); printlim(opts, &limit, &limits_tbl[i]);
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
@ -604,7 +608,7 @@ shell_builtin_ulimit(char **argv)
getrlimit(limits_tbl[i].cmd, &limit); getrlimit(limits_tbl[i].cmd, &limit);
if (!val_str) { if (!val_str) {
if (opt_cnt > 1) if (opt_cnt > 1)
printf("-%c: %-30s ", limit_chars[i], limits_tbl[i].name); printf("%-32s(-%c) ", limits_tbl[i].name, limit_chars[i]);
printlim(opts, &limit, &limits_tbl[i]); printlim(opts, &limit, &limits_tbl[i]);
} else { } else {
rlim_t val = RLIM_INFINITY; rlim_t val = RLIM_INFINITY;