diff options
-rw-r--r-- | shell/shell_common.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/shell/shell_common.c b/shell/shell_common.c index dcbe0d109..f95a35e8b 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c | |||
@@ -324,12 +324,18 @@ struct limits { | |||
324 | uint8_t factor_shift; /* shift by to get rlim_{cur,max} values */ | 324 | uint8_t factor_shift; /* shift by to get rlim_{cur,max} values */ |
325 | }; | 325 | }; |
326 | 326 | ||
327 | /* Order of entries matches order in which bash prints "ulimit -a" */ | ||
327 | static const struct limits limits_tbl[] ALIGN2 = { | 328 | static const struct limits limits_tbl[] ALIGN2 = { |
328 | { RLIMIT_CORE, 9, }, // -c | 329 | { RLIMIT_CORE, 9, }, // -c |
329 | { RLIMIT_DATA, 10, }, // -d | 330 | { RLIMIT_DATA, 10, }, // -d |
331 | #ifdef RLIMIT_NICE | ||
330 | { RLIMIT_NICE, 0, }, // -e | 332 | { RLIMIT_NICE, 0, }, // -e |
331 | { RLIMIT_FSIZE, 9, }, // -f | ||
332 | #define LIMIT_F_IDX 3 | 333 | #define LIMIT_F_IDX 3 |
334 | #else | ||
335 | /* for example, Hurd */ | ||
336 | #define LIMIT_F_IDX 2 | ||
337 | #endif | ||
338 | { RLIMIT_FSIZE, 9, }, // -f | ||
333 | #ifdef RLIMIT_SIGPENDING | 339 | #ifdef RLIMIT_SIGPENDING |
334 | { RLIMIT_SIGPENDING, 0, }, // -i | 340 | { RLIMIT_SIGPENDING, 0, }, // -i |
335 | #endif | 341 | #endif |
@@ -364,13 +370,16 @@ static const struct limits limits_tbl[] ALIGN2 = { | |||
364 | { RLIMIT_LOCKS, 0, }, // -x | 370 | { RLIMIT_LOCKS, 0, }, // -x |
365 | #endif | 371 | #endif |
366 | }; | 372 | }; |
367 | // bash also shows: | 373 | // 1) bash also shows: |
368 | //pipe size (512 bytes, -p) 8 | 374 | //pipe size (512 bytes, -p) 8 |
375 | // 2) RLIMIT_RTTIME ("timeout for RT tasks in us") is not in the table | ||
369 | 376 | ||
370 | static const char limits_help[] ALIGN1 = | 377 | static const char limits_help[] ALIGN1 = |
371 | "core file size (blocks)" // -c | 378 | "core file size (blocks)" // -c |
372 | "\0""data seg size (kb)" // -d | 379 | "\0""data seg size (kb)" // -d |
380 | #ifdef RLIMIT_NICE | ||
373 | "\0""scheduling priority" // -e | 381 | "\0""scheduling priority" // -e |
382 | #endif | ||
374 | "\0""file size (blocks)" // -f | 383 | "\0""file size (blocks)" // -f |
375 | #ifdef RLIMIT_SIGPENDING | 384 | #ifdef RLIMIT_SIGPENDING |
376 | "\0""pending signals" // -i | 385 | "\0""pending signals" // -i |
@@ -410,7 +419,9 @@ static const char limits_help[] ALIGN1 = | |||
410 | static const char limit_chars[] ALIGN1 = | 419 | static const char limit_chars[] ALIGN1 = |
411 | "c" | 420 | "c" |
412 | "d" | 421 | "d" |
422 | #ifdef RLIMIT_NICE | ||
413 | "e" | 423 | "e" |
424 | #endif | ||
414 | "f" | 425 | "f" |
415 | #ifdef RLIMIT_SIGPENDING | 426 | #ifdef RLIMIT_SIGPENDING |
416 | "i" | 427 | "i" |
@@ -451,7 +462,9 @@ static const char limit_chars[] ALIGN1 = | |||
451 | static const char ulimit_opt_string[] ALIGN1 = "-HSa" | 462 | static const char ulimit_opt_string[] ALIGN1 = "-HSa" |
452 | "c::" | 463 | "c::" |
453 | "d::" | 464 | "d::" |
465 | #ifdef RLIMIT_NICE | ||
454 | "e::" | 466 | "e::" |
467 | #endif | ||
455 | "f::" | 468 | "f::" |
456 | #ifdef RLIMIT_SIGPENDING | 469 | #ifdef RLIMIT_SIGPENDING |
457 | "i::" | 470 | "i::" |
@@ -668,7 +681,7 @@ shell_builtin_ulimit(char **argv) | |||
668 | 681 | ||
669 | if (opt_cnt == 0) { | 682 | if (opt_cnt == 0) { |
670 | /* "bare ulimit": treat it as if it was -f */ | 683 | /* "bare ulimit": treat it as if it was -f */ |
671 | getrlimit(limits_tbl[LIMIT_F_IDX].cmd, &limit); | 684 | getrlimit(RLIMIT_FSIZE, &limit); |
672 | printlim(opts, &limit, &limits_tbl[LIMIT_F_IDX]); | 685 | printlim(opts, &limit, &limits_tbl[LIMIT_F_IDX]); |
673 | } | 686 | } |
674 | 687 | ||