diff options
author | Ron Yorston <rmy@pobox.com> | 2021-01-14 13:28:49 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-01-14 13:28:49 +0000 |
commit | 89963b524d211e1aec12b72b3725be05ee95c8cf (patch) | |
tree | 48590aef62b7ee7686b7898256f29def8d9c50b9 /shell/shell_common.c | |
parent | 9aa5a829070392c2ac6494d0c4e674c0c2bc7dab (diff) | |
parent | 2b7c1aa92c68524559a2067609d09309d5c09adc (diff) | |
download | busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.gz busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.tar.bz2 busybox-w32-89963b524d211e1aec12b72b3725be05ee95c8cf.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'shell/shell_common.c')
-rw-r--r-- | shell/shell_common.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/shell/shell_common.c b/shell/shell_common.c index a6ee60851..1897fee3b 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c | |||
@@ -393,12 +393,18 @@ struct limits { | |||
393 | uint8_t factor_shift; /* shift by to get rlim_{cur,max} values */ | 393 | uint8_t factor_shift; /* shift by to get rlim_{cur,max} values */ |
394 | }; | 394 | }; |
395 | 395 | ||
396 | static const struct limits limits_tbl[] = { | 396 | /* Order of entries matches order in which bash prints "ulimit -a" */ |
397 | static const struct limits limits_tbl[] ALIGN2 = { | ||
397 | { RLIMIT_CORE, 9, }, // -c | 398 | { RLIMIT_CORE, 9, }, // -c |
398 | { RLIMIT_DATA, 10, }, // -d | 399 | { RLIMIT_DATA, 10, }, // -d |
400 | #ifdef RLIMIT_NICE | ||
399 | { RLIMIT_NICE, 0, }, // -e | 401 | { RLIMIT_NICE, 0, }, // -e |
400 | { RLIMIT_FSIZE, 9, }, // -f | ||
401 | #define LIMIT_F_IDX 3 | 402 | #define LIMIT_F_IDX 3 |
403 | #else | ||
404 | /* for example, Hurd */ | ||
405 | #define LIMIT_F_IDX 2 | ||
406 | #endif | ||
407 | { RLIMIT_FSIZE, 9, }, // -f | ||
402 | #ifdef RLIMIT_SIGPENDING | 408 | #ifdef RLIMIT_SIGPENDING |
403 | { RLIMIT_SIGPENDING, 0, }, // -i | 409 | { RLIMIT_SIGPENDING, 0, }, // -i |
404 | #endif | 410 | #endif |
@@ -433,13 +439,16 @@ static const struct limits limits_tbl[] = { | |||
433 | { RLIMIT_LOCKS, 0, }, // -x | 439 | { RLIMIT_LOCKS, 0, }, // -x |
434 | #endif | 440 | #endif |
435 | }; | 441 | }; |
436 | // bash also shows: | 442 | // 1) bash also shows: |
437 | //pipe size (512 bytes, -p) 8 | 443 | //pipe size (512 bytes, -p) 8 |
444 | // 2) RLIMIT_RTTIME ("timeout for RT tasks in us") is not in the table | ||
438 | 445 | ||
439 | static const char limits_help[] ALIGN1 = | 446 | static const char limits_help[] ALIGN1 = |
440 | "core file size (blocks)" // -c | 447 | "core file size (blocks)" // -c |
441 | "\0""data seg size (kb)" // -d | 448 | "\0""data seg size (kb)" // -d |
449 | #ifdef RLIMIT_NICE | ||
442 | "\0""scheduling priority" // -e | 450 | "\0""scheduling priority" // -e |
451 | #endif | ||
443 | "\0""file size (blocks)" // -f | 452 | "\0""file size (blocks)" // -f |
444 | #ifdef RLIMIT_SIGPENDING | 453 | #ifdef RLIMIT_SIGPENDING |
445 | "\0""pending signals" // -i | 454 | "\0""pending signals" // -i |
@@ -479,7 +488,9 @@ static const char limits_help[] ALIGN1 = | |||
479 | static const char limit_chars[] ALIGN1 = | 488 | static const char limit_chars[] ALIGN1 = |
480 | "c" | 489 | "c" |
481 | "d" | 490 | "d" |
491 | #ifdef RLIMIT_NICE | ||
482 | "e" | 492 | "e" |
493 | #endif | ||
483 | "f" | 494 | "f" |
484 | #ifdef RLIMIT_SIGPENDING | 495 | #ifdef RLIMIT_SIGPENDING |
485 | "i" | 496 | "i" |
@@ -520,7 +531,9 @@ static const char limit_chars[] ALIGN1 = | |||
520 | static const char ulimit_opt_string[] ALIGN1 = "-HSa" | 531 | static const char ulimit_opt_string[] ALIGN1 = "-HSa" |
521 | "c::" | 532 | "c::" |
522 | "d::" | 533 | "d::" |
534 | #ifdef RLIMIT_NICE | ||
523 | "e::" | 535 | "e::" |
536 | #endif | ||
524 | "f::" | 537 | "f::" |
525 | #ifdef RLIMIT_SIGPENDING | 538 | #ifdef RLIMIT_SIGPENDING |
526 | "i::" | 539 | "i::" |
@@ -737,7 +750,7 @@ shell_builtin_ulimit(char **argv) | |||
737 | 750 | ||
738 | if (opt_cnt == 0) { | 751 | if (opt_cnt == 0) { |
739 | /* "bare ulimit": treat it as if it was -f */ | 752 | /* "bare ulimit": treat it as if it was -f */ |
740 | getrlimit(limits_tbl[LIMIT_F_IDX].cmd, &limit); | 753 | getrlimit(RLIMIT_FSIZE, &limit); |
741 | printlim(opts, &limit, &limits_tbl[LIMIT_F_IDX]); | 754 | printlim(opts, &limit, &limits_tbl[LIMIT_F_IDX]); |
742 | } | 755 | } |
743 | 756 | ||